<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Coverage Report</title>
<link title="Style" type="text/css" rel="stylesheet" href="css/main.css"/>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body>
<h5>Coverage Report - org.jsimpledb.kv.raft.RaftKVDatabase</h5>
<div class="separator">&nbsp;</div>
<table class="report">
<thead><tr>  <td class="heading">Classes in this File</td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Line Coverage</a></td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Branch Coverage</a></td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Complexity</a></td></tr></thead>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/658</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/672</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$2</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/5</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$3</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$4</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/5</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$5</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$6</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/1</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$AbstractPrefixFunction</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$CandidateRole</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/47</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/30</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$ErrorLoggingRunnable</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$FollowerRole</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/371</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/324</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$FollowerRole$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/6</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$FollowerRole$PendingRequest</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/7</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$FollowerRole$PendingWrite</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/9</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/392</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/294</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$2</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$3</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$4</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$5</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$LeaderRole$UpdateFollowerService</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/13</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/8</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$MostRecentView</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/14</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/8</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$NewLogEntry</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/33</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/18</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$NonLeaderRole</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/25</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/8</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$NonLeaderRole$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$PrefixAdjustFunction</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$PrefixKeyRangeFunction</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$PrefixPutFunction</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/110</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/64</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$2</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$3</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$4</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$AbstractTransactionService</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/18</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/8</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$CheckReadyTransactionService</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Role$CheckWaitingTransactionService</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Service</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$ServiceThread</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/4</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Timer</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/39</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/40</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>
  <tr><td><a href="org.jsimpledb.kv.raft.RaftKVDatabase.html">RaftKVDatabase$Timer$PendingTimeout</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/7</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:0px"><span class="text">0/2</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.5132743362831858;</span>3.513</td></tr>

</table>
<div class="separator">&nbsp;</div>
<table cellspacing="0" cellpadding="0" class="src">
<tr>  <td class="numLine">&nbsp;1</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">/*</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * Copyright (C) 2014 Archie L. Cobbs. All rights reserved.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;5</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * $Id: org.jsimpledb.kv.raft.RaftKVDatabase.html 939 2015-05-29 01:16:17Z archie.cobbs $</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;6</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;7</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;8</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">package</span> org.jsimpledb.kv.raft;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;9</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;10</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.base.Function;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;11</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.base.Preconditions;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;12</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.base.Predicate;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;13</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.base.Predicates;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;14</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.collect.Iterables;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;15</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.primitives.Bytes;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;16</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;17</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.BufferedInputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;18</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.ByteArrayInputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;19</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.ByteArrayOutputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;20</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.DataInputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;21</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.DataOutputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;22</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.File;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;23</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.FileInputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;24</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.IOException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;25</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.ByteBuffer;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;26</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.channels.FileChannel;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;27</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.file.Files;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;28</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.file.StandardCopyOption;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;29</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.file.StandardOpenOption;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;30</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.security.SecureRandom;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;31</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.AbstractMap;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;32</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.ArrayList;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;33</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Arrays;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;34</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Collections;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;35</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.HashMap;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;36</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.HashSet;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;37</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Iterator;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;38</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.LinkedHashSet;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;39</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.List;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;40</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Map;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;41</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.NavigableSet;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;42</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.NoSuchElementException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;43</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ExecutionException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;44</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.Executors;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;45</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.RejectedExecutionException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;46</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ScheduledExecutorService;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;47</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ScheduledFuture;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;48</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ThreadFactory;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;49</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.TimeUnit;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;50</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.regex.Pattern;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;51</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;52</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.annotation.PostConstruct;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;53</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.annotation.PreDestroy;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;54</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;55</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.dellroad.stuff.io.ByteBufferInputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;56</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.dellroad.stuff.io.ByteBufferOutputStream;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;57</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.dellroad.stuff.java.TimedWait;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;58</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.iq80.leveldb.Options;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;59</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.iq80.leveldb.impl.Iq80DBFactory;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;60</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.CloseableKVStore;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;61</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.KVDatabase;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;62</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.KVStore;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;63</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.KVTransactionException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;64</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.KeyRange;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;65</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.KeyRanges;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;66</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.RetryTransactionException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;67</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.StaleTransactionException;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;68</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.leveldb.LevelDBKVStore;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;69</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.mvcc.AtomicKVStore;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;70</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.mvcc.MutableView;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;71</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.mvcc.Mutations;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;72</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.mvcc.Reads;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;73</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.mvcc.Writes;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;74</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.AppendRequest;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;75</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.AppendResponse;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;76</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.CommitRequest;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;77</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.CommitResponse;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;78</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.GrantVote;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;79</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.InstallSnapshot;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;80</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.Message;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;81</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.MessageSwitch;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;82</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.msg.RequestVote;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;83</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.net.Network;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;84</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.raft.net.TCPNetwork;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;85</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.kv.util.PrefixKVStore;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;86</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.util.ByteUtil;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;87</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.jsimpledb.util.LongEncoder;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;88</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.slf4j.Logger;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;89</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.slf4j.LoggerFactory;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;90</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;91</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;92</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * A distributed {@link org.jsimpledb.kv.KVDatabase} based on the Raft consensus algorithm.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;93</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;94</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;95</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * Raft defines a distributed consensus algorithm for maintaining a shared state machine.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;96</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * Each Raft node maintains a complete copy of the state machine. Cluster nodes elect a</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;97</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * leader who manages updates to the state machine and provides for consistent readds.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;98</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * As long as as a node is part of a majority, the state machine is fully operational.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;99</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;100</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;101</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * {@link RaftKVDatabase} turns</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;102</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * this into a transactional key/value database with linearizable ACID semantics:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;103</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;104</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;The Raft state machine is the key/value store data.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;105</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;Unapplied log entries are stored on disk as serialized {@link Writes}, and also cached in memory.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;106</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;On leaders only, the {@link Writes} associated with some number of the most recently applied log entries</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;107</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      are cached in memory for time &lt;i&gt;T&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt; since creation, where &lt;i&gt;T&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt; is the</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;108</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      maximum supported transaction duration (see below for how these cached {@link Writes} are used).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;109</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      This caching is subject to &lt;i&gt;M&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt;, which limits the total memory used by memory-cached</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;110</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      {@link Writes}; if reached, these cached {@link Writes} are discarded early.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;111</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;Concurrent transactions are supported through a simple optimistic locking MVCC scheme (same as used by</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;112</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      {@link org.jsimpledb.kv.mvcc.SnapshotKVDatabase}):</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;113</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;114</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;Transactions execute locally until commit time, using a {@link MutableView} to collect mutations.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;115</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          The {@link MutableView} is based on the local node's most recent log entry (whether committed or not);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          this is called the &lt;i&gt;base term and index&lt;/i&gt; for the transaction.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;117</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;On commit, the transaction's {@link Reads}, {@link Writes}, and base index and term are</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;118</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          {@linkplain CommitRequest sent} to the leader.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;119</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;The leader confirms that the log entry corresponding to the transaction's base index and term either:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;120</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;121</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          &lt;li&gt;Is still present in its own log and not yet applied to the state machine (in which case the</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;122</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *              {@link Writes} are available with the log entry); or&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;123</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          &lt;li&gt;Corresponds to an already applied log entry whose {@link Writes} are still cached in memory.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;124</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;125</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          If this is not the case, then the transaction's base log entry is too old (older than &lt;i&gt;T&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt;,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;126</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          or was committed early due to memory pressure), and so the transaction is rejected with a</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;127</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          {@link RetryTransactionException}. Otherwise, the {@link Writes} associated with all log entries</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;128</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          after the transaction's base log entry are available.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;129</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;The leader confirms that the {@link Writes} associated with log entries created after the transaction's</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;130</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          base log entry do not create linearizability violations when {@linkplain Reads#isConflict compared against}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;131</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          the transaction's {@link Reads}. If so, the transaction is rejected with a retry.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;132</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;The leader adds a new log entry consisting of the transaction's {@link Writes} to its log.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;133</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          The associated term and index become the transaction's &lt;i&gt;commit term and index&lt;/i&gt;; the leader</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;134</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          then {@linkplain CommitResponse replies} to the follower with this information.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;135</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;When the follower sees a log entry appear in its log matching the transaction's commit term and index, and</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;136</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          that log entry has been committed (in the Raft sense), the transaction is also committed.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;137</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;li&gt;As an optimization, when the leader sends a log entry to the same follower who committed the corresponding</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *          transaction in the first place, only the transaction ID is sent, because the follower already has the data.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;139</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;141</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;For transactions occurring on a leader, the logic is the same except of course no network communication occurs.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;142</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;For read-only transactions, the leader does not create a new log entry; instead, the transaction's commit</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      term and index are set to the term and index of the last entry in the leader's log. The leader also calculates its</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      current "leader lease timeout", which is the earliest time at which it is possible for another leader to be elected.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;145</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      This is calculated as the time in the past at which the leader sent {@link AppendRequest}'s to a majority of followers</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;146</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      who have since responded, plus the {@linkplain #setMinElectionTimeout minimum election timeout}, minus a small adjustment</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;147</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      for possible clock drift (this assumes all nodes have the same minimum election timeout configured). If the current</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;148</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      time is prior to the leader lease timeout, the transaction may be committed immediately; otherwise, the current time</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;149</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      is returned to the follower as minimum required leader lease timeout before the transaction may be committed.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;150</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;Included with each {@link AppendRequest} is the leader's current timestamp and lease timeout, so followers can commit</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;151</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      any waiting read-only transactions. Leaders keep track of which followers are waiting on which leader lease</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;152</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      timeout values, and when the leader lease timeout advances to allow a follower to commit a transaction, the follower</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;153</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      is notified with an immediate {@link AppendRequest} update.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;A weaker consistency guarantee for read-only transactions (serializable but not linearizable) is also possible; see</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      {@link RaftKVTransaction#setReadOnlySnapshot RaftKVTransaction.setReadOnlySnapshot()}.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;157</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;158</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;&lt;b&gt;Limitations&lt;/b&gt;&lt;/p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;159</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;160</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;161</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;A transaction's mutations must fit in memory.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;162</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;An {@link AtomicKVStore} is required to store local persistent state;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;163</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      if none is configured, a {@link LevelDBKVStore} is used.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;164</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;All nodes must be configured with the same {@linkplain #setMinElectionTimeout minimum election timeout}.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;165</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;Due to the optimistic locking approach used, this implementation will perform poorly when there is a high</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;166</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      rate of conflicting transactions; the result will be many transaction retries.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;167</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;Performance will suffer when the amount of data associated with a typical transaction cannot be delivered</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;168</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      quickly and reliably over the network.&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;169</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;170</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;171</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;&lt;b&gt;Cluster Configuration&lt;/b&gt;&lt;/p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;172</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;173</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;174</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * Instances support dynamic cluster configuration changes at runtime. Initially, all nodes are in an &lt;i&gt;unconfigured&lt;/i&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;175</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * state, where nothing has been added to the Raft log yet and no cluster is defined. Unconfigured nodes are passive: they</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;176</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * stay in follower mode (i.e., they will not start elections), and they disallow local transactions that make any changes</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;177</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * (other than as described below to initialize a new cluster).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;178</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;179</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;180</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * A node is configured if and only if it has a &lt;i&gt;configuration&lt;/i&gt;. A cluster configuration consists of the identites of</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;181</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * the nodes in the cluster, and their corresponding network addresses. Once a node &lt;i&gt;configured&lt;/i&gt;, a separate issue</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;182</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * is whether a node is &lt;i&gt;included&lt;/i&gt; in its own configuration. A node that is not included in its own configuration</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;183</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * does not count its own vote for elections and log commits, but otherwise functions normally in the cluster.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;184</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;185</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;186</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * An unconfigured node becomes configured when either:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;187</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;188</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;An {@link AppendRequest} is received from a leader of some existing cluster, in which case the node</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;189</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      joins the cluster and applies the received cluster configuration; or&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;190</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *  &lt;li&gt;{@link RaftKVTransaction#configChange RaftKVTransaction.configChange()} is invoked and committed within</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;191</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *      a local transaction, which creates a new cluster and configures it to contain the local node&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;192</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;193</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;194</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;195</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * On the first commit, newly created clusters are assigned a random 32-bit cluster ID. This ID is included in all</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;196</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * messages sent over the network, and adopted by unconfigured nodes that join the cluster. Configured nodes will discard</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;197</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * incoming messages containing a different cluster ID. This prevents data corruption that can occur if nodes from two</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;198</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * different clusters are inadvertently "mixed" together.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;199</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;200</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;201</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * Once a node joins a cluster (identified by cluster ID), it cannot be reassigned to a different cluster without first</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;202</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * returning it to the unconfigured state; to do that, it must be shut it down and its persistent state directory deleted.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;203</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;204</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * @see &lt;a href="https://raftconsensus.github.io/"&gt;The Raft Consensus Algorithm&lt;/a&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;205</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;206</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<span class="keyword">public</span> <span class="keyword">class</span> RaftKVDatabase <span class="keyword">implements</span> KVDatabase {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;207</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;208</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;209</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default minimum election timeout ({@value #DEFAULT_MIN_ELECTION_TIMEOUT}ms).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;210</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;211</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMinElectionTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;212</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;213</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_MIN_ELECTION_TIMEOUT = 750;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;214</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;215</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;216</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default maximum election timeout ({@value #DEFAULT_MAX_ELECTION_TIMEOUT}ms).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;217</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;218</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMaxElectionTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;219</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;220</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_MAX_ELECTION_TIMEOUT = 1000;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;221</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;222</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;223</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default heartbeat timeout ({@value DEFAULT_HEARTBEAT_TIMEOUT}ms).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;224</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;225</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setHeartbeatTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;226</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;227</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_HEARTBEAT_TIMEOUT = 200;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;228</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;229</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;230</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default maximum supported outstanding transaction duration ({@value DEFAULT_MAX_TRANSACTION_DURATION}ms).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;231</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;232</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMaxTransactionDuration</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;233</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;234</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_MAX_TRANSACTION_DURATION = 10 * 1000;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;235</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;236</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;237</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default maximum supported applied log entry memory usage ({@value DEFAULT_MAX_APPLIED_LOG_MEMORY} bytes).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;238</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;239</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMaxAppliedLogMemory</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;240</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;241</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">long</span> DEFAULT_MAX_APPLIED_LOG_MEMORY = 100 * 1024 * 1024;                <span class="comment">// 100MB</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;242</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;243</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;244</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default transaction commit timeout ({@value DEFAULT_COMMIT_TIMEOUT}).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;245</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;246</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setCommitTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;247</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see RaftKVTransaction#setTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;248</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;249</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_COMMIT_TIMEOUT = 5000;                                      <span class="comment">// 5 seconds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;250</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;251</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Internal constants</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;252</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> MAX_SNAPSHOT_TRANSMIT_AGE = (<span class="keyword">int</span>)TimeUnit.SECONDS.toMillis(90);    <span class="comment">// 90 seconds</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;253</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> MAX_SLOW_FOLLOWER_APPLY_DELAY_HEARTBEATS = 10;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;254</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> MAX_APPLIED_LOG_ENTRIES = 32;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;255</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> FOLLOWER_LINGER_HEARTBEATS = 3;                <span class="comment">// how long to keep updating removed followers</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;256</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">float</span> MAX_CLOCK_DRIFT = 0.01f;                     <span class="comment">// max clock drift (ratio) in one min election timeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;257</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;258</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// File prefixes and suffixes</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;259</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String TX_FILE_PREFIX = <span class="string">"tx-"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;260</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String TEMP_FILE_PREFIX = <span class="string">"temp-"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;261</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String TEMP_FILE_SUFFIX = <span class="string">".tmp"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;262</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String KVSTORE_FILE_SUFFIX = <span class="string">".kvstore"</span>;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;263</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Pattern TEMP_FILE_PATTERN = Pattern.compile(<span class="string">".*"</span> + Pattern.quote(TEMP_FILE_SUFFIX));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;264</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Pattern KVSTORE_FILE_PATTERN = Pattern.compile(<span class="string">".*"</span> + Pattern.quote(KVSTORE_FILE_SUFFIX));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;265</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;266</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Keys for persistent Raft state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;267</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] CLUSTER_ID_KEY = ByteUtil.parse(<span class="string">"0001"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;268</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] CURRENT_TERM_KEY = ByteUtil.parse(<span class="string">"0002"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;269</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] LAST_APPLIED_TERM_KEY = ByteUtil.parse(<span class="string">"0003"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;270</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] LAST_APPLIED_INDEX_KEY = ByteUtil.parse(<span class="string">"0004"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;271</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] LAST_APPLIED_CONFIG_KEY = ByteUtil.parse(<span class="string">"0005"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;272</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] VOTED_FOR_KEY = ByteUtil.parse(<span class="string">"0006"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;273</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;274</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Prefix for all state machine key/value keys</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;275</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] STATE_MACHINE_PREFIX = ByteUtil.parse(<span class="string">"80"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;276</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;277</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Logging</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;278</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">final</span> Logger log = LoggerFactory.getLogger(<span class="keyword">this</span>.getClass());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;279</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;280</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Configuration state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;281</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> Network network = <span class="keyword">new</span> TCPNetwork();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;282</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> String identity;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;283</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> AtomicKVStore kvstore;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;284</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> minElectionTimeout = DEFAULT_MIN_ELECTION_TIMEOUT;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;285</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> maxElectionTimeout = DEFAULT_MAX_ELECTION_TIMEOUT;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;286</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> heartbeatTimeout = DEFAULT_HEARTBEAT_TIMEOUT;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;287</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> maxTransactionDuration = DEFAULT_MAX_TRANSACTION_DURATION;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;288</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> commitTimeout = DEFAULT_COMMIT_TIMEOUT;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;289</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> maxAppliedLogMemory = DEFAULT_MAX_APPLIED_LOG_MEMORY;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;290</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> File logDir;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;291</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;292</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Raft runtime state</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;293</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> Role role;                                                  <span class="comment">// Raft state: LEADER, FOLLOWER, or CANDIDATE</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;294</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> SecureRandom random;                                        <span class="comment">// used to randomize election timeout, etc.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;295</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">int</span> clusterId;                                              <span class="comment">// cluster ID (zero if unconfigured - usually)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;296</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> currentTerm;                                           <span class="comment">// current Raft term (zero if unconfigured)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;297</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> commitIndex;                                           <span class="comment">// current Raft commit index (zero if unconfigured)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;298</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> lastAppliedTerm;                                       <span class="comment">// key/value store last applied term (zero if unconfigured)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;299</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> lastAppliedIndex;                                      <span class="comment">// key/value store last applied index (zero if unconfigured)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;300</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">final</span> ArrayList&lt;LogEntry&gt; raftLog = <span class="keyword">new</span> ArrayList&lt;&gt;();      <span class="comment">// unapplied log entries (empty if unconfigured)</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;301</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> Map&lt;String, String&gt; lastAppliedConfig;                      <span class="comment">// key/value store last applied config (empty if none)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;302</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> Map&lt;String, String&gt; currentConfig;                          <span class="comment">// most recent cluster config (empty if unconfigured)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;303</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;304</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Non-Raft runtime state</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;305</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> AtomicKVStore kv;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;306</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> FileChannel logDirChannel;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;307</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> ScheduledExecutorService executor;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;308</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> String returnAddress;                                       <span class="comment">// return address for message currently being processed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;309</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">final</span> HashSet&lt;String&gt; transmitting = <span class="keyword">new</span> HashSet&lt;&gt;();       <span class="comment">// network addresses whose output queues are not empty</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;310</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">final</span> HashMap&lt;Long, RaftKVTransaction&gt; openTransactions = <span class="keyword">new</span> HashMap&lt;&gt;();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;311</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">final</span> LinkedHashSet&lt;Service&gt; pendingService = <span class="keyword">new</span> LinkedHashSet&lt;&gt;();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;312</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> performingService;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;313</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> shuttingDown;                                       <span class="comment">// prevents new transactions from being created</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;314</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;315</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Configuration</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;316</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;317</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;318</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the {@link AtomicKVStore} in which local persistent state is stored.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;319</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;320</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;321</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * If this property is left unconfigured, by default a {@link LevelDBKVStore} is created when</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;322</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * {@link #start} is invoked and shutdown on {@link #stop}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;323</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;324</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param kvstore local persistent data store</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;325</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;326</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;327</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setKVStore(AtomicKVStore kvstore) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;328</td>  <td class="nbHitsUncovered"><a title="Line 328: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 328: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;329</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.kvstore = kvstore;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;330</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;331</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;332</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;333</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the directory in which uncommitted log entries are stored.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;334</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;335</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;336</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Required property.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;337</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;338</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param directory log directory</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;339</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;340</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;341</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setLogDirectory(File directory) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;342</td>  <td class="nbHitsUncovered"><a title="Line 342: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 342: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;343</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.logDir = directory;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;344</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;345</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;346</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;347</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the {@link Network} to use for inter-node communication.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;348</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;349</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;350</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * By default, a {@link TCPNetwork} instance is used.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;351</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;352</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param network network implementation; must not be {@linkplain Network#start started}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;353</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;354</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;355</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setNetwork(Network network) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;356</td>  <td class="nbHitsUncovered"><a title="Line 356: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 356: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;357</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.network = network;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;358</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;359</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;360</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;361</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the Raft identity.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;362</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;363</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;364</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Required property unless this is a single-node cluster.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;365</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;366</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param identity unique Raft identity of this node in its cluster</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;367</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;368</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;369</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setIdentity(String identity) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;370</td>  <td class="nbHitsUncovered"><a title="Line 370: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 370: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;371</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.identity = identity;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;372</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;373</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;374</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;375</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Get this node's Raft identity.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;376</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;377</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return the unique identity of this node in its cluster</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;378</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;379</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> String getIdentity() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;380</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.identity;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;381</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;382</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;383</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;384</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the minimum election timeout.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;385</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;386</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;387</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This must be set to a value greater than the {@linkplain #setHeartbeatTimeout heartbeat timeout}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;388</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;389</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;390</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_MIN_ELECTION_TIMEOUT}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;391</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;392</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;393</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;b&gt;Warning:&lt;/b&gt; currently all nodes must have the same configured minimum election timeout,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;394</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * otherwise read-only transactions are not guaranteed to be completely up-to-date.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;395</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;396</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param timeout minimum election timeout in milliseconds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;397</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;398</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code timeout &lt;= 0}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;399</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;400</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setMinElectionTimeout(<span class="keyword">int</span> timeout) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;401</td>  <td class="nbHitsUncovered"><a title="Line 401: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 401: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(timeout &gt; 0, <span class="string">"timeout &lt;= 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;402</td>  <td class="nbHitsUncovered"><a title="Line 402: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 402: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;403</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.minElectionTimeout = timeout;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;404</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;405</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;406</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;407</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the maximum election timeout.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;408</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;409</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;410</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_MAX_ELECTION_TIMEOUT}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;411</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;412</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param timeout maximum election timeout in milliseconds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;413</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;414</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code timeout &lt;= 0}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;415</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;416</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setMaxElectionTimeout(<span class="keyword">int</span> timeout) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;417</td>  <td class="nbHitsUncovered"><a title="Line 417: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 417: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(timeout &gt; 0, <span class="string">"timeout &lt;= 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;418</td>  <td class="nbHitsUncovered"><a title="Line 418: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 418: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;419</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.maxElectionTimeout = timeout;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;420</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;421</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;422</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;423</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the heartbeat timeout.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;424</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;425</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;426</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This must be set to a value less than the {@linkplain #setMinElectionTimeout minimum election timeout}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;427</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;428</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;429</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_HEARTBEAT_TIMEOUT}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;430</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;431</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param timeout heartbeat timeout in milliseconds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;432</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is already started</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;433</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code timeout &lt;= 0}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;434</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;435</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setHeartbeatTimeout(<span class="keyword">int</span> timeout) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;436</td>  <td class="nbHitsUncovered"><a title="Line 436: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 436: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(timeout &gt; 0, <span class="string">"timeout &lt;= 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;437</td>  <td class="nbHitsUncovered"><a title="Line 437: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 437: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role == <span class="keyword">null</span>, <span class="string">"already started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;438</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.heartbeatTimeout = timeout;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;439</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;440</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;441</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;442</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the maximum supported duration for outstanding transactions.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;443</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;444</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;445</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value is the &lt;i&gt;T&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt; value from the {@linkplain RaftKVDatabase overview}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;446</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * A larger value means more memory may be used.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;447</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;448</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;449</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value may be changed while this instance is already running.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;450</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;451</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;452</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_MAX_TRANSACTION_DURATION}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;453</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;454</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param duration maximum supported duration for outstanding transactions in milliseconds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;455</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code duration &lt;= 0}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;456</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMaxAppliedLogMemory</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;457</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;458</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setMaxTransactionDuration(<span class="keyword">int</span> duration) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;459</td>  <td class="nbHitsUncovered"><a title="Line 459: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 459: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(duration &gt; 0, <span class="string">"duration &lt;= 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;460</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.maxTransactionDuration = duration;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;461</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;462</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;463</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;464</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the maximum allowed memory used for caching log entries that have already been applied to the state machine.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;465</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;466</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;467</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value is the &lt;i&gt;M&lt;sub&gt;max&lt;/sub&gt;&lt;/i&gt; value from the {@linkplain RaftKVDatabase overview}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;468</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * A higher value means transactions may be larger and/or stay open longer without causing a {@link RetryTransactionException}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;469</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;470</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;471</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value is approximate, and only affects leaders; followers do not cache applied log entries.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;472</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;473</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;474</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value may be changed while this instance is already running.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;475</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;476</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;477</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_MAX_APPLIED_LOG_MEMORY}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;478</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;479</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param memory maximum allowed memory usage for cached applied log entries</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;480</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code memory &lt;= 0}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;481</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see #setMaxTransactionDuration</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;482</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;483</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setMaxAppliedLogMemory(<span class="keyword">long</span> memory) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;484</td>  <td class="nbHitsUncovered"><a title="Line 484: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 484: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(memory &gt; 0, <span class="string">"memory &lt;= 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;485</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.maxAppliedLogMemory = memory;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;486</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;487</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;488</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;489</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configure the default transaction commit timeout.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;490</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;491</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;492</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value determines how transactions will wait once {@link RaftKVTransaction#commit commit()}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;493</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * is invoked for the commit to succeed. This can be overridden on a per-transaction basis via</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;494</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * {@link RaftKVTransaction#setTimeout}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;495</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;496</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;497</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This value may be changed while this instance is already running.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;498</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;499</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;500</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Default is {@link #DEFAULT_COMMIT_TIMEOUT}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;501</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;502</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param timeout transaction commit timeout in milliseconds, or zero for unlimited</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;503</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if {@code timeout} is negative</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;504</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @see RaftKVTransaction#setTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;505</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;506</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> setCommitTimeout(<span class="keyword">int</span> timeout) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;507</td>  <td class="nbHitsUncovered"><a title="Line 507: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 507: Conditional coverage 0% (0/2).">        Preconditions.checkArgument(timeout &gt;= 0, <span class="string">"timeout &lt; 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;508</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.commitTimeout = commitTimeout;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;509</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;510</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;511</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;512</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;513</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;514</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Start this instance.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;515</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;516</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;517</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Does nothing if already started or in the process of shutting down.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;518</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;/p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;519</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;520</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is not properly configured</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;521</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalArgumentException if persistent data is corrupted</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;522</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IOException if an I/O error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;523</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;524</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    @PostConstruct</pre></td></tr>
<tr>  <td class="numLine">&nbsp;525</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> start() <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;526</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;527</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;528</td>  <td class="nbHitsUncovered"><a title="Line 528: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 528: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;529</td>  <td class="nbHitsUncovered"><a title="Line 529: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 529: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;530</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;531</td>  <td class="nbHitsUncovered"><a title="Line 531: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 531: Conditional coverage 0% (0/2).">        Preconditions.checkState(!<span class="keyword">this</span>.shuttingDown, <span class="string">"shutdown in progress"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;532</td>  <td class="nbHitsUncovered"><a title="Line 532: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 532: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.logDir != <span class="keyword">null</span>, <span class="string">"no log directory configured"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;533</td>  <td class="nbHitsUncovered"><a title="Line 533: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 533: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.network != <span class="keyword">null</span>, <span class="string">"no network configured"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;534</td>  <td class="nbHitsUncovered"><a title="Line 534: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 534: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.kv == <span class="keyword">null</span>, <span class="string">"key/value store exists"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;535</td>  <td class="nbHitsUncovered"><a title="Line 535: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 535: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.minElectionTimeout &lt;= <span class="keyword">this</span>.maxElectionTimeout, <span class="string">"minElectionTimeout &gt; maxElectionTimeout"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;536</td>  <td class="nbHitsUncovered"><a title="Line 536: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 536: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.heartbeatTimeout &lt; <span class="keyword">this</span>.minElectionTimeout, <span class="string">"heartbeatTimeout &gt;= minElectionTimeout"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;537</td>  <td class="nbHitsUncovered"><a title="Line 537: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 537: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.identity != <span class="keyword">null</span>, <span class="string">"no identity configured"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;538</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;539</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Log</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;540</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"starting "</span> + <span class="keyword">this</span> + <span class="string">" in directory "</span> + <span class="keyword">this</span>.logDir);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;541</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;542</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Start up local database</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;543</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">boolean</span> success = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;544</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;545</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;546</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Create/verify log directory</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;547</td>  <td class="nbHitsUncovered"><a title="Line 547: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 547: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (!<span class="keyword">this</span>.logDir.exists() &amp;&amp; !<span class="keyword">this</span>.logDir.isDirectory())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;548</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"failed to create directory `"</span> + <span class="keyword">this</span>.logDir + <span class="string">"'"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;549</td>  <td class="nbHitsUncovered"><a title="Line 549: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 549: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.logDir.isDirectory())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;550</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"file `"</span> + <span class="keyword">this</span>.logDir + <span class="string">"' is not a directory"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;551</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;552</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// By default use an atomic key/value store based on LevelDB if not explicitly specified</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;553</td>  <td class="nbHitsUncovered"><a title="Line 553: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 553: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.kvstore != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;554</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.kv = <span class="keyword">this</span>.kvstore;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;555</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;556</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> File leveldbDir = <span class="keyword">new</span> File(<span class="keyword">this</span>.logDir, <span class="string">"levedb"</span> + KVSTORE_FILE_SUFFIX);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;557</td>  <td class="nbHitsUncovered"><a title="Line 557: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 557: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (!leveldbDir.exists() &amp;&amp; !leveldbDir.mkdirs())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;558</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"failed to create directory `"</span> + leveldbDir + <span class="string">"'"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;559</td>  <td class="nbHitsUncovered"><a title="Line 559: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 559: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!leveldbDir.isDirectory())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;560</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"file `"</span> + leveldbDir + <span class="string">"' is not a directory"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;561</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.kv = <span class="keyword">new</span> LevelDBKVStore(<span class="keyword">new</span> Iq80DBFactory().open(leveldbDir, <span class="keyword">new</span> Options().createIfMissing(<span class="keyword">true</span>)));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;562</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;563</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;564</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Open directory containing log entry files so we have a way to fsync() it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;565</td>  <td class="nbHitsUncovered"><a title="Line 565: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 565: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.logDirChannel == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;566</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.logDirChannel = FileChannel.open(<span class="keyword">this</span>.logDir.toPath(), StandardOpenOption.READ);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;567</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;568</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Create randomizer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;569</td>  <td class="nbHitsUncovered"><a title="Line 569: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 569: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.random == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;570</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.random = <span class="keyword">new</span> SecureRandom();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;571</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;572</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Start up executor thread</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;573</td>  <td class="nbHitsUncovered"><a title="Line 573: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 573: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.executor == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;574</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor = Executors.newSingleThreadScheduledExecutor(<span class="keyword">new</span> ThreadFactory() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;575</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;576</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">public</span> Thread newThread(Runnable action) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;577</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="keyword">new</span> ServiceThread(action);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;578</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;579</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            });</pre></td></tr>
<tr>  <td class="numLine">&nbsp;580</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;581</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Start network</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;582</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.network.start(<span class="keyword">new</span> Network.Handler() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;583</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;584</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">public</span> <span class="keyword">void</span> handle(String sender, ByteBuffer buf) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;585</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    RaftKVDatabase.<span class="keyword">this</span>.handle(sender, buf);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;586</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;587</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;588</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;589</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">public</span> <span class="keyword">void</span> outputQueueEmpty(String address) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;590</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    RaftKVDatabase.<span class="keyword">this</span>.outputQueueEmpty(address);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;591</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;592</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            });</pre></td></tr>
<tr>  <td class="numLine">&nbsp;593</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;594</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Reload persistent raft info</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;595</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.clusterId = (<span class="keyword">int</span>)<span class="keyword">this</span>.decodeLong(CLUSTER_ID_KEY, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;596</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.currentTerm = <span class="keyword">this</span>.decodeLong(CURRENT_TERM_KEY, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;597</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String votedFor = <span class="keyword">this</span>.decodeString(VOTED_FOR_KEY, <span class="keyword">null</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;598</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.lastAppliedTerm = <span class="keyword">this</span>.decodeLong(LAST_APPLIED_TERM_KEY, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;599</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.lastAppliedIndex = <span class="keyword">this</span>.decodeLong(LAST_APPLIED_INDEX_KEY, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;600</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.lastAppliedConfig = <span class="keyword">this</span>.decodeConfig(LAST_APPLIED_CONFIG_KEY);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;601</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.currentConfig = <span class="keyword">this</span>.buildCurrentConfig();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;602</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;603</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If we crashed part way through a snapshot install, recover by resetting state machine</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;604</td>  <td class="nbHitsUncovered"><a title="Line 604: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 604: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.lastAppliedTerm &lt; 0 || <span class="keyword">this</span>.lastAppliedIndex &lt; 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;605</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"detected partially applied snapshot, resetting state machine"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;606</td>  <td class="nbHitsUncovered"><a title="Line 606: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 606: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.resetStateMachine(<span class="keyword">true</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;607</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"error resetting state machine"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;608</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;609</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;610</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Initialize commit index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;611</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.commitIndex = <span class="keyword">this</span>.lastAppliedIndex;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;612</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;613</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Reload outstanding log entries from disk</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;614</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.loadLog();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;615</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;616</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Show recovered state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;617</td>  <td class="nbHitsUncovered"><a title="Line 617: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 617: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">this</span>.info(<span class="string">"recovered Raft state:"</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;618</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  clusterId="</span> + (<span class="keyword">this</span>.clusterId != 0 ? String.format(<span class="string">"0x%08x"</span>, <span class="keyword">this</span>.clusterId) : <span class="string">"none"</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;619</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  currentTerm="</span> + <span class="keyword">this</span>.currentTerm</pre></td></tr>
<tr>  <td class="numLine">&nbsp;620</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  lastApplied="</span> + <span class="keyword">this</span>.lastAppliedTerm + <span class="string">"/"</span> + <span class="keyword">this</span>.lastAppliedIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;621</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  lastAppliedConfig="</span> + <span class="keyword">this</span>.lastAppliedConfig</pre></td></tr>
<tr>  <td class="numLine">&nbsp;622</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  currentConfig="</span> + <span class="keyword">this</span>.currentConfig</pre></td></tr>
<tr>  <td class="numLine">&nbsp;623</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  votedFor="</span> + (votedFor != <span class="keyword">null</span> ? <span class="string">"\""</span> + votedFor + <span class="string">"\""</span> : <span class="string">"nobody"</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;624</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"\n  log="</span> + <span class="keyword">this</span>.raftLog);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;625</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;626</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Validate recovered state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;627</td>  <td class="nbHitsUncovered"><a title="Line 627: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 627: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.isConfigured()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;628</td>  <td class="nbHitsUncovered"><a title="Line 628: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 628: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.clusterId != 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;629</td>  <td class="nbHitsUncovered"><a title="Line 629: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 629: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.currentTerm &gt; 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;630</td>  <td class="nbHitsUncovered"><a title="Line 630: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 630: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.getLastLogTerm() &gt; 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;631</td>  <td class="nbHitsUncovered"><a title="Line 631: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 631: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.getLastLogIndex() &gt; 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;632</td>  <td class="nbHitsUncovered"><a title="Line 632: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 632: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(!<span class="keyword">this</span>.currentConfig.isEmpty());</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;633</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;634</td>  <td class="nbHitsUncovered"><a title="Line 634: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 634: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.lastAppliedTerm == 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;635</td>  <td class="nbHitsUncovered"><a title="Line 635: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 635: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.lastAppliedIndex == 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;636</td>  <td class="nbHitsUncovered"><a title="Line 636: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 636: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.currentTerm == 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;637</td>  <td class="nbHitsUncovered"><a title="Line 637: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 637: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.getLastLogTerm() == 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;638</td>  <td class="nbHitsUncovered"><a title="Line 638: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 638: Conditional coverage 0% (0/2).">                Preconditions.checkArgument(<span class="keyword">this</span>.getLastLogIndex() == 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;639</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Preconditions.checkArgument(<span class="keyword">this</span>.currentConfig.isEmpty());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;640</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Preconditions.checkArgument(<span class="keyword">this</span>.raftLog.isEmpty());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;641</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;642</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;643</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Start as follower (with unknown leader)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;644</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.changeRole(<span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>, <span class="keyword">null</span>, <span class="keyword">null</span>, votedFor));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;645</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;646</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;647</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            success = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;648</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">finally</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;649</td>  <td class="nbHitsUncovered"><a title="Line 649: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 649: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!success)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;650</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.cleanup();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;651</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;652</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;653</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;654</td>  <td class="nbHitsUncovered"><a title="Line 654: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 654: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;655</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;656</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;657</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;658</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Stop this instance.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;659</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;660</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;661</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Does nothing if not {@linkplain #start started} or in the process of shutting down.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;662</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;/p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;663</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;664</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    @PreDestroy</pre></td></tr>
<tr>  <td class="numLine">&nbsp;665</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">void</span> stop() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;666</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;667</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Set flag to prevent new transactions</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;668</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;669</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;670</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;671</td>  <td class="nbHitsUncovered"><a title="Line 671: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 671: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;672</td>  <td class="nbHitsUncovered"><a title="Line 672: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 672: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.role == <span class="keyword">null</span> || <span class="keyword">this</span>.shuttingDown)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;673</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;674</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;675</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Set shutting down flag</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;676</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"starting shutdown of "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;677</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.shuttingDown = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;678</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;679</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Fail all remaining open transactions</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;680</td>  <td class="nbHitsUncovered"><a title="Line 680: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 680: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">new</span> ArrayList&lt;RaftKVTransaction&gt;(<span class="keyword">this</span>.openTransactions.values())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;681</td>  <td class="nbHitsUncovered"><a title="Line 681: Conditional coverage 0% (0/4).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 681: Conditional coverage 0% (0/4).">                <span class="keyword">switch</span> (tx.getState()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;682</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> EXECUTING:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;683</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    tx.rollback();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;684</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;685</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> COMMIT_READY:</pre></td></tr>
<tr>  <td class="numLine">&nbsp;686</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> COMMIT_WAITING:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;687</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.fail(tx, <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"database shutdown"</span>));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;688</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;689</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> COMPLETED:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;690</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;691</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">default</span>:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;692</td>  <td class="nbHitsUncovered"><a title="Line 692: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 692: Conditional coverage 0% (0/2).">                    <span class="keyword">assert</span> <span class="keyword">false</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;693</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">break</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;694</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;695</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;696</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;697</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sleep while we wait for transactions to clean themselves up</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;698</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">boolean</span> done = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;699</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;700</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                done = TimedWait.wait(<span class="keyword">this</span>, 5000, <span class="keyword">new</span> org.dellroad.stuff.java.Predicate() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;701</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;702</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">public</span> <span class="keyword">boolean</span> test() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;703</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span> RaftKVDatabase.<span class="keyword">this</span>.openTransactions.isEmpty();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;704</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;705</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                });</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;706</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (InterruptedException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;707</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Thread.currentThread().interrupt();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;708</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;709</td>  <td class="nbHitsUncovered"><a title="Line 709: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 709: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!done)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;710</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.warn(<span class="string">"open transactions not cleaned up during shutdown"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;711</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;712</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;713</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Shut down the executor and wait for pending tasks to finish</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;714</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.executor.shutdownNow();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;715</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;716</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor.awaitTermination(1000, TimeUnit.MILLISECONDS);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;717</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (InterruptedException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;718</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            Thread.currentThread().interrupt();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;719</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;720</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;721</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Final cleanup</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;722</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;723</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;724</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;725</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;726</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;727</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;728</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"completed shutdown of "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;729</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;730</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;731</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> cleanup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;732</td>  <td class="nbHitsUncovered"><a title="Line 732: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 732: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;733</td>  <td class="nbHitsUncovered"><a title="Line 733: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 733: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.openTransactions.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;734</td>  <td class="nbHitsUncovered"><a title="Line 734: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 734: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;735</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.role.shutdown();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;736</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.role = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;737</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;738</td>  <td class="nbHitsUncovered"><a title="Line 738: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 738: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.executor != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;739</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor.shutdownNow();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;740</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;741</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.executor.awaitTermination(1000, TimeUnit.MILLISECONDS);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;742</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (InterruptedException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;743</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Thread.currentThread().interrupt();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;744</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;745</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;746</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;747</td>  <td class="nbHitsUncovered"><a title="Line 747: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 747: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.kv != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;748</td>  <td class="nbHitsUncovered"><a title="Line 748: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 748: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.kvstore == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;749</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LevelDBKVStore ldb = (LevelDBKVStore)<span class="keyword">this</span>.kv;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;750</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Util.closeIfPossible(ldb);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;751</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Util.closeIfPossible(ldb.getDB());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;752</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;753</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.kv = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;754</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;755</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        Util.closeIfPossible(<span class="keyword">this</span>.logDirChannel);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;756</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.logDirChannel = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;757</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.raftLog.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;758</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.random = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;759</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.network.stop();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;760</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.currentTerm = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;761</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.commitIndex = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;762</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.clusterId = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;763</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedTerm = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;764</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedIndex = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;765</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedConfig = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;766</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.currentConfig = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;767</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.transmitting.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;768</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.pendingService.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;769</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.shuttingDown = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;770</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;771</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;772</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;773</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Initialize our in-memory state from the persistent state reloaded from disk.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;774</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * This is invoked on initial startup.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;775</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;776</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> loadLog() <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;777</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;778</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;779</td>  <td class="nbHitsUncovered"><a title="Line 779: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 779: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;780</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;781</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Scan for log entry files</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;782</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.raftLog.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;783</td>  <td class="nbHitsUncovered"><a title="Line 783: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 783: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (File file : <span class="keyword">this</span>.logDir.listFiles()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;784</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;785</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Is this a log entry file?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;786</td>  <td class="nbHitsUncovered"><a title="Line 786: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 786: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (LogEntry.LOG_FILE_PATTERN.matcher(file.getName()).matches()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;787</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"recovering log file "</span> + file.getName());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;788</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raftLog.add(LogEntry.fromFile(file));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;789</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">continue</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;790</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;791</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;792</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Is this a leftover temporary file?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;793</td>  <td class="nbHitsUncovered"><a title="Line 793: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 793: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (TEMP_FILE_PATTERN.matcher(file.getName()).matches()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;794</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"deleting leftover temporary file "</span> + file.getName());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;795</td>  <td class="nbHitsUncovered"><a title="Line 795: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 795: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!file.delete())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;796</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"failed to delete leftover temporary file "</span> + file);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;797</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">continue</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;798</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;799</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;800</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Is this a KV store directory (expected)?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;801</td>  <td class="nbHitsUncovered"><a title="Line 801: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 801: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (KVSTORE_FILE_PATTERN.matcher(file.getName()).matches())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;802</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">continue</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;803</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;804</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Unknown</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;805</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"ignoring unrecognized file "</span> + file.getName() + <span class="string">" in my log directory"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;806</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;807</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;808</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Verify we have a contiguous range of log entries starting from the snapshot index; discard bogus log files</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;809</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        Collections.sort(<span class="keyword">this</span>.raftLog, LogEntry.SORT_BY_INDEX);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;810</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">long</span> lastTermSeen = <span class="keyword">this</span>.lastAppliedTerm;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;811</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">long</span> expectedIndex = <span class="keyword">this</span>.lastAppliedIndex + 1;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;812</td>  <td class="nbHitsUncovered"><a title="Line 812: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 812: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (Iterator&lt;LogEntry&gt; i = <span class="keyword">this</span>.raftLog.iterator(); i.hasNext(); ) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;813</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> LogEntry logEntry = i.next();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;814</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            String error = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;815</td>  <td class="nbHitsUncovered"><a title="Line 815: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 815: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (logEntry.getTerm() &lt; lastTermSeen)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;816</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                error = <span class="string">"term "</span> + logEntry.getTerm() + <span class="string">" &lt; last applied term "</span> + lastTermSeen;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;817</td>  <td class="nbHitsUncovered"><a title="Line 817: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 817: Conditional coverage 0% (0/2).">            <span class="keyword">else</span> <span class="keyword">if</span> (logEntry.getIndex() &lt; <span class="keyword">this</span>.lastAppliedIndex)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;818</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                error = <span class="string">"index "</span> + logEntry.getIndex() + <span class="string">" &lt; last applied index "</span> + <span class="keyword">this</span>.lastAppliedIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;819</td>  <td class="nbHitsUncovered"><a title="Line 819: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 819: Conditional coverage 0% (0/2).">            <span class="keyword">else</span> <span class="keyword">if</span> (logEntry.getIndex() != expectedIndex)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;820</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                error = <span class="string">"index "</span> + logEntry.getIndex() + <span class="string">" != expected index "</span> + expectedIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;821</td>  <td class="nbHitsUncovered"><a title="Line 821: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 821: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (error != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;822</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.warn(<span class="string">"deleting bogus log file "</span> + logEntry.getFile().getName() + <span class="string">": "</span> + error);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;823</td>  <td class="nbHitsUncovered"><a title="Line 823: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 823: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!logEntry.getFile().delete())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;824</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"failed to delete bogus log file "</span> + logEntry.getFile());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;825</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                i.remove();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;826</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;827</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                expectedIndex++;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;828</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                lastTermSeen = logEntry.getTerm();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;829</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;830</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;831</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"recovered "</span> + <span class="keyword">this</span>.raftLog.size() + <span class="string">" Raft log entries: "</span> + <span class="keyword">this</span>.raftLog);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;832</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;833</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Rebuild current configuration</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;834</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.currentConfig = <span class="keyword">this</span>.buildCurrentConfig();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;835</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;836</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;837</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> Map&lt;String, String&gt; buildCurrentConfig() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;838</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;839</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Start with last applied config</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;840</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> HashMap&lt;String, String&gt; config = <span class="keyword">new</span> HashMap&lt;&gt;(<span class="keyword">this</span>.lastAppliedConfig);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;841</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;842</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Apply any changes found in uncommitted log entries</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;843</td>  <td class="nbHitsUncovered"><a title="Line 843: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 843: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (LogEntry logEntry : <span class="keyword">this</span>.raftLog)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;844</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            logEntry.applyConfigChange(config);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;845</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;846</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;847</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> config;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;848</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;849</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;850</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Configuration Stuff</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;851</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;852</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;853</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Retrieve the unique 32-bit ID for this node's cluster.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;854</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;855</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;856</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * A value of zero indicates an unconfigured system. Usually the reverse true, though an unconfigured system</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;857</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * can have a non-zero cluster ID in the rare case where an error occurred persisting the initial log entry.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;858</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;859</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return unique cluster ID, or zero if this node is unconfigured</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;860</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;861</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">int</span> getClusterId() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;862</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.clusterId;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;863</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;864</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;865</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;866</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Retrieve the current cluster configuration as understood by this node.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;867</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;868</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;869</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Configuration changes are performed and committed in the context of a normal transaction; see</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;870</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * {@link RaftKVTransaction#configChange RaftKVTransaction.configChange()}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;871</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;872</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;873</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * If this system is unconfigured, an emtyp map is returned (and vice-versa).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;874</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;875</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return current configuration mapping from node identity to network address, or empty if this node is unconfigured</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;876</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;877</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> Map&lt;String, String&gt; getCurrentConfig() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;878</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">new</span> HashMap&lt;&gt;(<span class="keyword">this</span>.currentConfig);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;879</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;880</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;881</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;882</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Determine whether this instance is configured.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;883</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;884</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;885</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * A node is configured iff it has added at least one Raft log entry (because the first log entry in any</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;886</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * new cluster always includes a configuration change that adds the first node in the cluster).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;887</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;888</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return true if this instance is configured, otherwise false</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;889</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;890</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">boolean</span> isConfigured() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;891</td>  <td class="nbHitsUncovered"><a title="Line 891: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 891: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">return</span> <span class="keyword">this</span>.lastAppliedIndex &gt; 0 || !<span class="keyword">this</span>.raftLog.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;892</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;893</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;894</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;895</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Determine whether this node thinks that it is part of the cluster, as currently configured on this node.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;896</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;897</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return true if this instance is part of the cluster, otherwise false</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;898</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;899</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">boolean</span> isClusterMember() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;900</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.isClusterMember(<span class="keyword">this</span>.identity);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;901</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;902</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;903</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;904</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Determine whether this node thinks that the specified node is part of the cluster, as currently configured on this node.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;905</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;906</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param node node identity</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;907</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return true if the specified node is part of the cluster, otherwise false</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;908</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;909</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">boolean</span> isClusterMember(String node) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;910</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.currentConfig.containsKey(node);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;911</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;912</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;913</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Transactions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;914</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;915</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;916</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Create a new transaction.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;917</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;918</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws IllegalStateException if this instance is not {@linkplain #start started} or in the process of shutting down</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;919</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;920</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;921</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">synchronized</span> RaftKVTransaction createTransaction() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;922</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;923</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;924</td>  <td class="nbHitsUncovered"><a title="Line 924: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 924: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;925</td>  <td class="nbHitsUncovered"><a title="Line 925: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 925: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.role != <span class="keyword">null</span>, <span class="string">"not started"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;926</td>  <td class="nbHitsUncovered"><a title="Line 926: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 926: Conditional coverage 0% (0/2).">        Preconditions.checkState(!<span class="keyword">this</span>.shuttingDown, <span class="string">"shutting down"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;927</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;928</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Base transaction on the most recent log entry. This is itself a form of optimistic locking: we assume that the</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;929</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// most recent log entry has a high probability of being committed (in the Raft sense), which is of course required</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;930</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// in order to commit any transaction based on it.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;931</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> MostRecentView view = <span class="keyword">new</span> MostRecentView();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;932</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;933</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Create transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;934</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> RaftKVTransaction tx = <span class="keyword">new</span> RaftKVTransaction(<span class="keyword">this</span>,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;935</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          <span class="keyword">this</span>.getLastLogTerm(), <span class="keyword">this</span>.getLastLogIndex(), view.getSnapshot(), view.getView());</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;936</td>  <td class="nbHitsUncovered"><a title="Line 936: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 936: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;937</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"created new transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;938</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.openTransactions.put(tx.getTxId(), tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;939</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;940</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Set default commit timeout</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;941</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.setTimeout(<span class="keyword">this</span>.commitTimeout);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;942</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;943</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;944</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> tx;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;945</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;946</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;947</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;948</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Commit a transaction.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;949</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;950</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">void</span> commit(<span class="keyword">final</span> RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;951</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;952</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;953</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Mark transaction as "commit ready" - service thread will do the rest</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;954</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;955</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;956</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;957</td>  <td class="nbHitsUncovered"><a title="Line 957: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 957: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;958</td>  <td class="nbHitsUncovered"><a title="Line 958: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 958: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> <span class="keyword">this</span>.role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;959</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;960</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Check tx state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;961</td>  <td class="nbHitsUncovered"><a title="Line 961: Conditional coverage 0% (0/3).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 961: Conditional coverage 0% (0/3).">                <span class="keyword">switch</span> (tx.getState()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;962</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> EXECUTING:</pre></td></tr>
<tr>  <td class="numLine">&nbsp;963</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;964</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Transition to COMMIT_READY state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;965</td>  <td class="nbHitsUncovered"><a title="Line 965: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 965: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;966</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.debug(<span class="string">"committing transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;967</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    tx.closeSnapshot();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;968</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    tx.setState(TxState.COMMIT_READY);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;969</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.requestService(<span class="keyword">this</span>.role.<span class="keyword">new</span> CheckReadyTransactionService(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;970</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;971</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Setup commit timer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;972</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">final</span> <span class="keyword">int</span> timeout = tx.getTimeout();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;973</td>  <td class="nbHitsUncovered"><a title="Line 973: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 973: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (timeout != 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;974</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">final</span> Timer commitTimer = <span class="keyword">new</span> Timer(<span class="string">"commit timer for "</span> + tx,</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;975</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                          <span class="keyword">new</span> Service(<span class="keyword">null</span>, <span class="string">"commit timeout for tx#"</span> + tx.getTxId()) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;976</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;977</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;978</td>  <td class="nbHitsUncovered"><a title="Line 978: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 978: Conditional coverage 0% (0/2).">                                <span class="keyword">switch</span> (tx.getState()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;979</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                <span class="keyword">case</span> COMMIT_READY:</pre></td></tr>
<tr>  <td class="numLine">&nbsp;980</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                <span class="keyword">case</span> COMMIT_WAITING:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;981</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                    RaftKVDatabase.<span class="keyword">this</span>.fail(tx, <span class="keyword">new</span> RetryTransactionException(tx,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;982</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                      <span class="string">"transaction failed to complete within "</span> + timeout + <span class="string">"ms (in state "</span> + tx.getState() + <span class="string">")"</span>));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;983</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;984</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                <span class="keyword">default</span>:</pre></td></tr>
<tr>  <td class="numLine">&nbsp;985</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                    <span class="keyword">break</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;986</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;987</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;988</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                        });</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;989</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        commitTimer.timeoutAfter(tx.getTimeout());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;990</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        tx.setCommitTimer(commitTimer);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;991</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;992</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">break</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;993</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">case</span> CLOSED:                                        <span class="comment">// this transaction has already been committed or rolled back</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;994</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> StaleTransactionException(tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;995</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">default</span>:                                            <span class="comment">// another thread is already doing the commit</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;996</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.warn(<span class="string">"simultaneous commit()'s requested for "</span> + tx + <span class="string">" by two different threads"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;997</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">break</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;998</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;999</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1000</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1001</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Wait for completion</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1002</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1003</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.getCommitFuture().get();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1004</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (InterruptedException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1005</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"thread interrupted while waiting for commit"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1006</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (ExecutionException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1007</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Throwable cause = e.getCause();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1008</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Util.prependCurrentStackTrace(cause, <span class="string">"Asynchronous Commit"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1009</td>  <td class="nbHitsUncovered"><a title="Line 1009: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1009: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (cause <span class="keyword">instanceof</span> Error)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1010</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> (Error)cause;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1011</td>  <td class="nbHitsUncovered"><a title="Line 1011: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1011: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (cause <span class="keyword">instanceof</span> RuntimeException)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1012</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> (RuntimeException)cause;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1013</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"commit failed"</span>, cause);           <span class="comment">// should never get here</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1014</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1015</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">finally</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1016</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.cleanupTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1017</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1018</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1019</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1020</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1021</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Rollback a transaction.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1022</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1023</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">synchronized</span> <span class="keyword">void</span> rollback(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1024</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1025</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1026</td>  <td class="nbHitsUncovered"><a title="Line 1026: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1026: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1027</td>  <td class="nbHitsUncovered"><a title="Line 1027: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1027: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1028</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1029</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check tx state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1030</td>  <td class="nbHitsUncovered"><a title="Line 1030: Conditional coverage 0% (0/3).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1030: Conditional coverage 0% (0/3).">        <span class="keyword">switch</span> (tx.getState()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1031</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">case</span> EXECUTING:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1032</td>  <td class="nbHitsUncovered"><a title="Line 1032: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1032: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1033</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"rolling back transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1034</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.cleanupTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1035</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1036</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">case</span> CLOSED:</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1037</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1038</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">default</span>:                                            <span class="comment">// another thread is currently committing!</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1039</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"simultaneous commit() and rollback() requested for "</span> + tx + <span class="string">" by two different threads"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1040</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">break</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1041</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1042</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1043</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1044</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> cleanupTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1045</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1046</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1047</td>  <td class="nbHitsUncovered"><a title="Line 1047: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1047: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1048</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.trace(<span class="string">"cleaning up transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1049</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1050</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Do any per-role cleanups</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1051</td>  <td class="nbHitsUncovered"><a title="Line 1051: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1051: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1052</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.role.cleanupForTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1053</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1054</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Close transaction's snapshot</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1055</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.closeSnapshot();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1056</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1057</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Cancel commit timer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1058</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> Timer commitTimer = tx.getCommitTimer();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1059</td>  <td class="nbHitsUncovered"><a title="Line 1059: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1059: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (commitTimer != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1060</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            commitTimer.cancel();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1061</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1062</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Remove from open transactions set</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1063</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.openTransactions.remove(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1064</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1065</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Transition to CLOSED</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1066</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.setState(TxState.CLOSED);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1067</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1068</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Notify waiting thread if doing shutdown</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1069</td>  <td class="nbHitsUncovered"><a title="Line 1069: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1069: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.shuttingDown)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1070</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.notify();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1071</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1072</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1073</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Mark a transaction as having succeeded</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1074</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">void</span> succeed(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1075</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1076</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1077</td>  <td class="nbHitsUncovered"><a title="Line 1077: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1077: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1078</td>  <td class="nbHitsUncovered"><a title="Line 1078: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1078: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1079</td>  <td class="nbHitsUncovered"><a title="Line 1079: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1079: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">if</span> (tx.getState().equals(TxState.COMPLETED) || tx.getState().equals(TxState.CLOSED))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1080</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1081</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1082</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Succeed transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1083</td>  <td class="nbHitsUncovered"><a title="Line 1083: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1083: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1084</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"successfully committed "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1085</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.getCommitFuture().succeed();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1086</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.setState(TxState.COMPLETED);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1087</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.role.cleanupForTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1088</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1089</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1090</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Mark a transaction as having failed</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1091</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">void</span> fail(RaftKVTransaction tx, Exception e) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1092</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1093</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1094</td>  <td class="nbHitsUncovered"><a title="Line 1094: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1094: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1095</td>  <td class="nbHitsUncovered"><a title="Line 1095: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1095: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1096</td>  <td class="nbHitsUncovered"><a title="Line 1096: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1096: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">if</span> (tx.getState().equals(TxState.COMPLETED) || tx.getState().equals(TxState.CLOSED))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1097</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1098</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1099</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Fail transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1100</td>  <td class="nbHitsUncovered"><a title="Line 1100: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1100: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1101</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"failed transaction "</span> + tx + <span class="string">": "</span> + e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1102</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.getCommitFuture().fail(e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1103</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        tx.setState(TxState.COMPLETED);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1104</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.role.cleanupForTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1105</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1106</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1107</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// DataView</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1108</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1109</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1110</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * A view of the database based on the most recent log entry, if any, otherwise directly on the committed key/value store.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1111</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Caller is responsible for eventually closing the snapshot.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1112</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1113</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">class</span> MostRecentView {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1114</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1115</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> CloseableKVStore snapshot;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> MutableView view;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1117</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1118</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> MostRecentView() {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1119</td>  <td class="nbHitsUncovered"><a title="Line 1119: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1119: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(RaftKVDatabase.<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1120</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1121</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Grab a snapshot of the key/value store</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1122</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.snapshot = RaftKVDatabase.<span class="keyword">this</span>.kv.snapshot();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1123</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1124</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Create a view of just the state machine keys and values and successively layer unapplied log entries</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1125</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            KVStore kview = PrefixKVStore.create(snapshot, STATE_MACHINE_PREFIX);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1126</td>  <td class="nbHitsUncovered"><a title="Line 1126: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1126: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (LogEntry logEntry : RaftKVDatabase.<span class="keyword">this</span>.raftLog) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1127</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Writes writes = logEntry.getWrites();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1128</td>  <td class="nbHitsUncovered"><a title="Line 1128: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1128: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!writes.isEmpty())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1129</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    kview = <span class="keyword">new</span> MutableView(kview, <span class="keyword">null</span>, logEntry.getWrites());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1130</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1131</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1132</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Finalize</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1133</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.view = <span class="keyword">new</span> MutableView(kview);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1134</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1135</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1136</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> CloseableKVStore getSnapshot() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1137</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.snapshot;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1139</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> MutableView getView() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1141</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.view;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1142</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1145</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1146</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1147</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1148</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Request service to be invoked after the current service (if any) completes.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1149</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1150</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1151</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * If {@code service} has an associated {@link Role}, and that {@link Role} is no longer active</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1152</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * when the service is handled, nothing will be done.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1153</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param service the service to perform</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> requestService(Service service) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1157</td>  <td class="nbHitsUncovered"><a title="Line 1157: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1157: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1158</td>  <td class="nbHitsUncovered"><a title="Line 1158: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1158: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (!<span class="keyword">this</span>.pendingService.add(service))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1159</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1160</td>  <td class="nbHitsUncovered"><a title="Line 1160: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1160: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.performingService)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1161</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1162</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1163</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.executor.submit(<span class="keyword">new</span> ErrorLoggingRunnable() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1164</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1165</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">protected</span> <span class="keyword">void</span> doRun() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1166</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    RaftKVDatabase.<span class="keyword">this</span>.handlePendingService();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1167</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1168</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            });</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1169</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (RejectedExecutionException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1170</td>  <td class="nbHitsUncovered"><a title="Line 1170: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1170: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.shuttingDown)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1171</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.warn(<span class="string">"executor task rejected, skipping"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1172</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1173</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1174</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1175</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Performs pending service requests (do not invoke directly)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1176</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> handlePendingService() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1177</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1178</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1179</td>  <td class="nbHitsUncovered"><a title="Line 1179: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1179: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1180</td>  <td class="nbHitsUncovered"><a title="Line 1180: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1180: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.currentThread() <span class="keyword">instanceof</span> ServiceThread;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1181</td>  <td class="nbHitsUncovered"><a title="Line 1181: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1181: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1182</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1183</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1184</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// While there is work to do, do it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1185</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.performingService = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1186</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1187</td>  <td class="nbHitsUncovered"><a title="Line 1187: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1187: Conditional coverage 0% (0/2).">            <span class="keyword">while</span> (!<span class="keyword">this</span>.pendingService.isEmpty()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1188</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Iterator&lt;Service&gt; i = <span class="keyword">this</span>.pendingService.iterator();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1189</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Service service = i.next();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1190</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                i.remove();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1191</td>  <td class="nbHitsUncovered"><a title="Line 1191: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1191: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">assert</span> service.getRole() == <span class="keyword">null</span> || service.getRole() == <span class="keyword">this</span>.role;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1192</td>  <td class="nbHitsUncovered"><a title="Line 1192: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1192: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1193</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"SERVICE ["</span> + service + <span class="string">"] in "</span> + <span class="keyword">this</span>.role);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1194</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                service.run();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1195</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1196</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">finally</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1197</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.performingService = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1198</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1199</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1200</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1201</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">class</span> ServiceThread <span class="keyword">extends</span> Thread {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1202</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        ServiceThread(Runnable action) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1203</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(action);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1204</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.setName(RaftKVDatabase.<span class="keyword">this</span> + <span class="string">" Service"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1205</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1206</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1207</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1208</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">abstract</span> <span class="keyword">static</span> <span class="keyword">class</span> Service <span class="keyword">implements</span> Runnable {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1209</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1210</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Role role;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1211</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> String desc;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1212</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1213</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> Service(Role role, String desc) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1214</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.role = role;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1215</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.desc = desc;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1216</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1217</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1218</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> Role getRole() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1219</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.role;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1220</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1221</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1222</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1223</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1224</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.desc;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1225</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1226</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1227</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1228</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Timer</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1229</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1230</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1231</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * One shot timer that {@linkplain #requestService requests} a {@link Service} on expiration.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1232</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1233</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">class</span> Timer {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1234</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1235</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Logger log = RaftKVDatabase.<span class="keyword">this</span>.log;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1236</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> String name;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1237</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Service service;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1238</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> ScheduledFuture&lt;?&gt; future;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1239</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> PendingTimeout pendingTimeout;                  <span class="comment">// non-null IFF timeout has not been handled yet</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1240</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> Timestamp timeoutDeadline;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1241</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1242</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> Timer(String name, Service service) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1243</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.name = name;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1244</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.service = service;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1245</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1246</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1247</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1248</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Stop timer if running.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1249</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1250</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws IllegalStateException if the lock object is not locked</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1251</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1252</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> cancel() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1253</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1254</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1255</td>  <td class="nbHitsUncovered"><a title="Line 1255: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1255: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(RaftKVDatabase.<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1256</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1257</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Cancel existing timer, if any</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1258</td>  <td class="nbHitsUncovered"><a title="Line 1258: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1258: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.future != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1259</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.future.cancel(<span class="keyword">false</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1260</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.future = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1261</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1262</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1263</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Ensure the previously scheduled action does nothing if case we lose the cancel() race condition</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1264</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingTimeout = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1265</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.timeoutDeadline = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1266</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1267</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1268</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1269</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * (Re)schedule this timer. Discards any previously scheduled timeout.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1270</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1271</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param delay delay before expiration in milliseonds</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1272</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return true if restarted, false if executor rejected the task</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1273</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws IllegalStateException if the lock object is not locked</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1274</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1275</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> timeoutAfter(<span class="keyword">int</span> delay) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1276</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1277</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1278</td>  <td class="nbHitsUncovered"><a title="Line 1278: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1278: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(RaftKVDatabase.<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1279</td>  <td class="nbHitsUncovered"><a title="Line 1279: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1279: Conditional coverage 0% (0/2).">            Preconditions.checkArgument(delay &gt;= 0, <span class="string">"delay &lt; 0"</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1280</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1281</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Cancel existing timeout action, if any</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1282</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.cancel();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1283</td>  <td class="nbHitsUncovered"><a title="Line 1283: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1283: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.future == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1284</td>  <td class="nbHitsUncovered"><a title="Line 1284: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1284: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.pendingTimeout == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1285</td>  <td class="nbHitsUncovered"><a title="Line 1285: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1285: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.timeoutDeadline == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1286</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1287</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Reschedule new timeout action</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1288</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.timeoutDeadline = <span class="keyword">new</span> Timestamp().offset(delay);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1289</td>  <td class="nbHitsUncovered"><a title="Line 1289: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1289: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1290</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                RaftKVDatabase.<span class="keyword">this</span>.trace(<span class="string">"rescheduling "</span> + <span class="keyword">this</span>.name + <span class="string">" for "</span> + <span class="keyword">this</span>.timeoutDeadline</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1291</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" ("</span> + delay + <span class="string">"ms from now)"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1292</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1293</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingTimeout = <span class="keyword">new</span> PendingTimeout();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1294</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1295</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.future = RaftKVDatabase.<span class="keyword">this</span>.executor.schedule(<span class="keyword">this</span>.pendingTimeout, delay, TimeUnit.MILLISECONDS);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1296</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (RejectedExecutionException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1297</td>  <td class="nbHitsUncovered"><a title="Line 1297: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1297: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!RaftKVDatabase.<span class="keyword">this</span>.shuttingDown)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1298</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    RaftKVDatabase.<span class="keyword">this</span>.warn(<span class="string">"can't restart timer"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1299</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1300</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1301</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1302</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1303</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Force timer to expire immediately.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1304</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1305</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> timeoutNow() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1306</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.timeoutAfter(0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1307</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1308</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1309</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1310</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Determine if this timer has expired and requires service handling, and reset it if so.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1311</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1312</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1313</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * If this timer is not running, has not yet expired, or has previously expired and this method was already</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1314</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * thereafter invoked, false is returned. Otherwise, true is returned, this timer is {@link #cancel}ed (if necessary),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1315</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * and the caller is expected to handle the implied service need.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1316</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1317</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return true if timer needs handling, false otherwise</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1318</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1319</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">boolean</span> pollForTimeout() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1320</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1321</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1322</td>  <td class="nbHitsUncovered"><a title="Line 1322: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1322: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(RaftKVDatabase.<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1323</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1324</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Has timer expired?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1325</td>  <td class="nbHitsUncovered"><a title="Line 1325: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1325: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.pendingTimeout == <span class="keyword">null</span> || !<span class="keyword">this</span>.timeoutDeadline.hasOccurred())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1326</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1327</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1328</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Yes, timer requires service</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1329</td>  <td class="nbHitsUncovered"><a title="Line 1329: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1329: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (Timer.<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1330</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                RaftKVDatabase.<span class="keyword">this</span>.trace(Timer.<span class="keyword">this</span>.name + <span class="string">" expired "</span> + -<span class="keyword">this</span>.timeoutDeadline.offsetFromNow() + <span class="string">"ms ago"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1331</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.cancel();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1332</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1333</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1334</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1335</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1336</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Determine if this timer is running, i.e., will expire or has expired but</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1337</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * {@link #pollForTimeout} has not been invoked yet.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1338</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1339</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">boolean</span> isRunning() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1340</td>  <td class="nbHitsUncovered"><a title="Line 1340: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1340: Conditional coverage 0% (0/2).">            <span class="keyword">return</span> <span class="keyword">this</span>.pendingTimeout != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1341</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1342</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1343</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">class</span> PendingTimeout <span class="keyword">extends</span> ErrorLoggingRunnable {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1344</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1345</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1346</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">protected</span> <span class="keyword">void</span> doRun() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1347</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">synchronized</span> (RaftKVDatabase.<span class="keyword">this</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1348</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1349</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Avoid cancel() race condition</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1350</td>  <td class="nbHitsUncovered"><a title="Line 1350: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1350: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (Timer.<span class="keyword">this</span>.pendingTimeout != <span class="keyword">this</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1351</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1352</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1353</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Trigger service</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1354</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    RaftKVDatabase.<span class="keyword">this</span>.requestService(Timer.<span class="keyword">this</span>.service);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1355</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1356</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1357</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1358</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1359</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1360</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Raft stuff</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1361</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1362</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1363</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Reset the persisted state machine to its initial state.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1364</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1365</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> resetStateMachine(<span class="keyword">boolean</span> initialize) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1366</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1367</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1368</td>  <td class="nbHitsUncovered"><a title="Line 1368: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1368: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1369</td>  <td class="nbHitsUncovered"><a title="Line 1369: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1369: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1370</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"resetting state machine"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1371</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1372</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Set invalid values while we make non-atomic changes, in case we crash in the middle</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1373</td>  <td class="nbHitsUncovered"><a title="Line 1373: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1373: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (!<span class="keyword">this</span>.recordLastApplied(-1, -1, <span class="keyword">null</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1374</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1375</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1376</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Delete all key/value pairs</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1377</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.kv.removeRange(STATE_MACHINE_PREFIX, ByteUtil.getKeyAfterPrefix(STATE_MACHINE_PREFIX));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1378</td>  <td class="nbHitsUncovered"><a title="Line 1378: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1378: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> !<span class="keyword">this</span>.kv.getRange(STATE_MACHINE_PREFIX, ByteUtil.getKeyAfterPrefix(STATE_MACHINE_PREFIX), <span class="keyword">false</span>).hasNext();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1379</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1380</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Delete all log files</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1381</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.raftLog.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1382</td>  <td class="nbHitsUncovered"><a title="Line 1382: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1382: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (File file : <span class="keyword">this</span>.logDir.listFiles()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1383</td>  <td class="nbHitsUncovered"><a title="Line 1383: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1383: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (LogEntry.LOG_FILE_PATTERN.matcher(file.getName()).matches()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1384</td>  <td class="nbHitsUncovered"><a title="Line 1384: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1384: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!file.delete())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1385</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"failed to delete log file "</span> + file);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1386</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1387</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1388</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1389</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Optionally finish intialization</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1390</td>  <td class="nbHitsUncovered"><a title="Line 1390: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1390: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">if</span> (initialize &amp;&amp; !<span class="keyword">this</span>.recordLastApplied(0, 0, <span class="keyword">null</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1391</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1392</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1393</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1394</td>  <td class="nbHitsUncovered"><a title="Line 1394: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1394: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1395</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"done resetting state machine"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1396</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1397</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1398</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1399</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1400</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Record the last applied term, index, and configuration in the persistent store.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1401</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1402</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> recordLastApplied(<span class="keyword">long</span> term, <span class="keyword">long</span> index, Map&lt;String, String&gt; config) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1403</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1404</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1405</td>  <td class="nbHitsUncovered"><a title="Line 1405: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1405: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1406</td>  <td class="nbHitsUncovered"><a title="Line 1406: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1406: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1407</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.trace(<span class="string">"updating state machine last applied to "</span> + term + <span class="string">"/"</span> + index + <span class="string">" with config "</span> + config);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1408</td>  <td class="nbHitsUncovered"><a title="Line 1408: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1408: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (config == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1409</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            config = <span class="keyword">new</span> HashMap&lt;String, String&gt;(0);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1410</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1411</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Prepare updates</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1412</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> Writes writes = <span class="keyword">new</span> Writes();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1413</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.getPuts().put(LAST_APPLIED_TERM_KEY, LongEncoder.encode(term));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1414</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.getPuts().put(LAST_APPLIED_INDEX_KEY, LongEncoder.encode(index));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1415</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.getPuts().put(LAST_APPLIED_CONFIG_KEY, <span class="keyword">this</span>.encodeConfig(config));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1416</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1417</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update persistent store</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1418</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1419</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.kv.mutate(writes, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1420</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1421</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.error(<span class="string">"error updating key/value store term/index to "</span> + term + <span class="string">"/"</span> + index, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1422</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1423</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1424</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1425</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update in-memory copy</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1426</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedTerm = Math.max(term, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1427</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedIndex = Math.max(index, 0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1428</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.lastAppliedConfig = config;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1429</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.commitIndex = <span class="keyword">this</span>.lastAppliedIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1430</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.currentConfig = <span class="keyword">this</span>.buildCurrentConfig();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1431</td>  <td class="nbHitsUncovered"><a title="Line 1431: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1431: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">if</span> (term &gt;= 0 &amp;&amp; index &gt;= 0)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1432</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"new current configuration: "</span> + <span class="keyword">this</span>.currentConfig);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1433</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1434</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1435</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1436</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1437</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Update and persist a new current term.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1438</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1439</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> advanceTerm(<span class="keyword">long</span> newTerm) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1440</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1441</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1442</td>  <td class="nbHitsUncovered"><a title="Line 1442: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1442: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1443</td>  <td class="nbHitsUncovered"><a title="Line 1443: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1443: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> newTerm &gt; <span class="keyword">this</span>.currentTerm;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1444</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"advancing current term from "</span> + <span class="keyword">this</span>.currentTerm + <span class="string">" -&gt; "</span> + newTerm);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1445</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1446</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update persistent store</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1447</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> Writes writes = <span class="keyword">new</span> Writes();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1448</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.getPuts().put(CURRENT_TERM_KEY, LongEncoder.encode(newTerm));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1449</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.setRemoves(<span class="keyword">new</span> KeyRanges(VOTED_FOR_KEY));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1450</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1451</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.kv.mutate(writes, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1452</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1453</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.error(<span class="string">"error persisting new term "</span> + newTerm, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1454</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1455</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1456</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1457</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update in-memory copy</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1458</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.currentTerm = newTerm;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1459</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1460</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1461</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1462</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1463</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Join the specified cluster.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1464</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1465</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param newClusterId cluster ID, or zero to have one randomly assigned</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1466</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1467</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> joinCluster(<span class="keyword">int</span> newClusterId) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1468</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1469</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1470</td>  <td class="nbHitsUncovered"><a title="Line 1470: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1470: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1471</td>  <td class="nbHitsUncovered"><a title="Line 1471: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1471: Conditional coverage 0% (0/2).">        Preconditions.checkState(<span class="keyword">this</span>.clusterId == 0);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1472</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1473</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Pick a new, random cluster ID if needed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1474</td>  <td class="nbHitsUncovered"><a title="Line 1474: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1474: Conditional coverage 0% (0/2).">        <span class="keyword">while</span> (newClusterId == 0)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1475</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            newClusterId = <span class="keyword">this</span>.random.nextInt();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1476</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1477</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Persist it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1478</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"joining cluster with ID "</span> + String.format(<span class="string">"0x%08x"</span>, newClusterId));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1479</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> Writes writes = <span class="keyword">new</span> Writes();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1480</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        writes.getPuts().put(CLUSTER_ID_KEY, LongEncoder.encode(newClusterId));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1481</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1482</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.kv.mutate(writes, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1483</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1484</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.error(<span class="string">"error updating key/value store with new cluster ID"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1485</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1486</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1487</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1488</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1489</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.clusterId = newClusterId;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1490</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1491</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1492</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1493</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1494</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Set the Raft role.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1495</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1496</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param role new role</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1497</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1498</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> changeRole(Role role) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1499</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1500</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1501</td>  <td class="nbHitsUncovered"><a title="Line 1501: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1501: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1502</td>  <td class="nbHitsUncovered"><a title="Line 1502: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1502: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1503</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1504</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Shutdown previous role (if any)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1505</td>  <td class="nbHitsUncovered"><a title="Line 1505: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1505: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1506</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.role.shutdown();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1507</td>  <td class="nbHitsUncovered"><a title="Line 1507: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1507: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Iterator&lt;Service&gt; i = <span class="keyword">this</span>.pendingService.iterator(); i.hasNext(); ) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1508</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Service service = i.next();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1509</td>  <td class="nbHitsUncovered"><a title="Line 1509: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1509: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (service.getRole() != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1510</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    i.remove();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1511</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1512</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1513</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1514</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Setup new role</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1515</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.role = role;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1516</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.role.setup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1517</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.info(<span class="string">"changing role to "</span> + role);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1518</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1519</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1520</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1521</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Append a log entry to the Raft log.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1522</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1523</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param term new log entry term</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1524</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param entry entry to add; the {@linkplain NewLogEntry#getTempFile temporary file} must be already durably persisted,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1525</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     *  and will be renamed</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1526</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return new {@link LogEntry}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1527</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws Exception if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1528</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1529</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> LogEntry appendLogEntry(<span class="keyword">long</span> term, NewLogEntry newLogEntry) <span class="keyword">throws</span> Exception {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1530</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1531</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1532</td>  <td class="nbHitsUncovered"><a title="Line 1532: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1532: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1533</td>  <td class="nbHitsUncovered"><a title="Line 1533: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1533: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.role != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1534</td>  <td class="nbHitsUncovered"><a title="Line 1534: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1534: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> newLogEntry != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1535</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1536</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Get file length</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1537</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> LogEntry.Data data = newLogEntry.getData();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1538</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> File tempFile = newLogEntry.getTempFile();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1539</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> <span class="keyword">long</span> fileLength = Util.getLength(tempFile);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1540</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1541</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Create new log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1542</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> LogEntry logEntry = <span class="keyword">new</span> LogEntry(term, <span class="keyword">this</span>.getLastLogIndex() + 1, <span class="keyword">this</span>.logDir, data, fileLength);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1543</td>  <td class="nbHitsUncovered"><a title="Line 1543: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1543: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1544</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.debug(<span class="string">"adding new log entry "</span> + logEntry + <span class="string">" using "</span> + tempFile.getName());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1545</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1546</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Atomically rename file and fsync() directory to durably persist</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1547</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        Files.move(tempFile.toPath(), logEntry.getFile().toPath(), StandardCopyOption.ATOMIC_MOVE);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1548</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.logDirChannel.force(<span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1549</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1550</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Add new log entry to in-memory log</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1551</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.raftLog.add(logEntry);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1552</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1553</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update current config</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1554</td>  <td class="nbHitsUncovered"><a title="Line 1554: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1554: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (logEntry.applyConfigChange(<span class="keyword">this</span>.currentConfig))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1555</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"new current configuration: "</span> + <span class="keyword">this</span>.currentConfig);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1556</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1557</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1558</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> logEntry;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1559</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1560</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1561</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> getLastLogIndex() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1562</td>  <td class="nbHitsUncovered"><a title="Line 1562: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1562: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1563</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.lastAppliedIndex + <span class="keyword">this</span>.raftLog.size();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1564</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1565</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1566</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> getLastLogTerm() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1567</td>  <td class="nbHitsUncovered"><a title="Line 1567: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1567: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1568</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.getLogTermAtIndex(<span class="keyword">this</span>.getLastLogIndex());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1569</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1570</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1571</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> getLogTermAtIndex(<span class="keyword">long</span> index) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1572</td>  <td class="nbHitsUncovered"><a title="Line 1572: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1572: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1573</td>  <td class="nbHitsUncovered"><a title="Line 1573: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1573: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> index &gt;= <span class="keyword">this</span>.lastAppliedIndex;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1574</td>  <td class="nbHitsUncovered"><a title="Line 1574: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1574: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> index &lt;= <span class="keyword">this</span>.getLastLogIndex();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1575</td>  <td class="nbHitsUncovered"><a title="Line 1575: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1575: Conditional coverage 0% (0/2).">        <span class="keyword">return</span> index == <span class="keyword">this</span>.lastAppliedIndex ? <span class="keyword">this</span>.lastAppliedTerm : <span class="keyword">this</span>.getLogEntryAtIndex(index).getTerm();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1576</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1577</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1578</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> LogEntry getLogEntryAtIndex(<span class="keyword">long</span> index) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1579</td>  <td class="nbHitsUncovered"><a title="Line 1579: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1579: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1580</td>  <td class="nbHitsUncovered"><a title="Line 1580: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1580: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> index &gt; <span class="keyword">this</span>.lastAppliedIndex;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1581</td>  <td class="nbHitsUncovered"><a title="Line 1581: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1581: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> index &lt;= <span class="keyword">this</span>.getLastLogIndex();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1582</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.raftLog.get((<span class="keyword">int</span>)(index - <span class="keyword">this</span>.lastAppliedIndex - 1));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1583</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1584</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1585</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1586</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Contains the information required to commit a new entry to the log.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1587</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1588</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">class</span> NewLogEntry {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1589</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1590</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> LogEntry.Data data;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1591</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> File tempFile;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1592</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1593</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1594</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Create an instance from a transaction and a temporary file</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1595</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1596</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param data log entry mutations</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1597</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws Exception if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1598</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1599</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> NewLogEntry(RaftKVTransaction tx, File tempFile) <span class="keyword">throws</span> IOException {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1600</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.data = <span class="keyword">new</span> LogEntry.Data(tx.getMutableView().getWrites(), tx.getConfigChange());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1601</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.tempFile = tempFile;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1602</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1603</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1604</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1605</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Create an instance from a transaction.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1606</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1607</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param data log entry mutations</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1608</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws Exception if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1609</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1610</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> NewLogEntry(RaftKVTransaction tx) <span class="keyword">throws</span> IOException {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1611</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.data = <span class="keyword">new</span> LogEntry.Data(tx.getMutableView().getWrites(), tx.getConfigChange());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1612</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.tempFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX, RaftKVDatabase.<span class="keyword">this</span>.logDir);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1613</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">try</span> (FileWriter output = <span class="keyword">new</span> FileWriter(<span class="keyword">this</span>.tempFile)) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1614</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LogEntry.writeData(output, data);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1615</td>  <td class="nbHitsUncovered"><a title="Line 1615: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1615: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            }</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1616</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1617</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1618</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1619</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Create an instance from a {@link LogEntry.Data} object.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1620</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1621</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param data mutation data</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1622</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws Exception if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1623</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1624</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> NewLogEntry(LogEntry.Data data) <span class="keyword">throws</span> IOException {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1625</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.data = data;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1626</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.tempFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX, RaftKVDatabase.<span class="keyword">this</span>.logDir);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1627</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">try</span> (FileWriter output = <span class="keyword">new</span> FileWriter(<span class="keyword">this</span>.tempFile)) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1628</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LogEntry.writeData(output, data);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1629</td>  <td class="nbHitsUncovered"><a title="Line 1629: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1629: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            }</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1630</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1631</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1632</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1633</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Create an instance from a serialized data in a {@link ByteBuffer}.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1634</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1635</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param buf buffer containing serialized mutations</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1636</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws Exception if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1637</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1638</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">public</span> NewLogEntry(ByteBuffer dataBuf) <span class="keyword">throws</span> IOException {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1639</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1640</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Copy data to temporary file</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1641</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.tempFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX, RaftKVDatabase.<span class="keyword">this</span>.logDir);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1642</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">try</span> (FileWriter output = <span class="keyword">new</span> FileWriter(<span class="keyword">this</span>.tempFile)) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1643</td>  <td class="nbHitsUncovered"><a title="Line 1643: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1643: Conditional coverage 0% (0/2).">                <span class="keyword">while</span> (dataBuf.hasRemaining())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1644</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    output.getFileOutputStream().getChannel().write(dataBuf);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1645</td>  <td class="nbHitsUncovered"><a title="Line 1645: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1645: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            }</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1646</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1647</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Avoid having two copies of the data in memory at once</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1648</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            dataBuf = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1649</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1650</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Deserialize data from file back into memory</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1651</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">try</span> (BufferedInputStream input = <span class="keyword">new</span> BufferedInputStream(<span class="keyword">new</span> FileInputStream(tempFile), 4096)) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1652</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.data = LogEntry.readData(input);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1653</td>  <td class="nbHitsUncovered"><a title="Line 1653: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1653: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            }</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1654</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1655</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1656</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> LogEntry.Data getData() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1657</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.data;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1658</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1659</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1660</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> File getTempFile() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1661</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.tempFile;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1662</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1663</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1664</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> cancel() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1665</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.tempFile.delete();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1666</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1667</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1668</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1669</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1670</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1671</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1672</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1673</td>  <td class="nbHitsUncovered"><a title="Line 1673: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1673: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">return</span> <span class="keyword">this</span>.getClass().getSimpleName()</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1674</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">"[identity="</span> + (<span class="keyword">this</span>.identity != <span class="keyword">null</span> ? <span class="string">"\""</span> + <span class="keyword">this</span>.identity + <span class="string">"\""</span> : <span class="keyword">null</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1675</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",logDir="</span> + <span class="keyword">this</span>.logDir</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1676</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",term="</span> + <span class="keyword">this</span>.currentTerm</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1677</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",commitIndex="</span> + <span class="keyword">this</span>.commitIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1678</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",lastApplied="</span> + <span class="keyword">this</span>.lastAppliedTerm + <span class="string">"/"</span> + <span class="keyword">this</span>.lastAppliedIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1679</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",raftLog="</span> + <span class="keyword">this</span>.raftLog</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1680</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">",role="</span> + <span class="keyword">this</span>.role</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1681</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + (<span class="keyword">this</span>.shuttingDown ? <span class="string">",shuttingDown"</span> : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1682</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          + <span class="string">"]"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1683</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1684</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1685</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Network.Handler and Messaging</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1686</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1687</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> handle(String sender, ByteBuffer buf) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1688</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1689</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Decode message</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1690</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">final</span> Message msg;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1691</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1692</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            msg = Message.decode(buf);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1693</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IllegalArgumentException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1694</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.error(<span class="string">"rec'd bogus message from "</span> + sender + <span class="string">", ignoring"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1695</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1696</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1697</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1698</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Receive message</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1699</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.receiveMessage(sender, msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1700</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1701</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1702</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> outputQueueEmpty(String address) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1703</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1704</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1705</td>  <td class="nbHitsUncovered"><a title="Line 1705: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1705: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1706</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1707</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Update transmitting status</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1708</td>  <td class="nbHitsUncovered"><a title="Line 1708: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1708: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (!<span class="keyword">this</span>.transmitting.remove(address))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1709</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1710</td>  <td class="nbHitsUncovered"><a title="Line 1710: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1710: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1711</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.trace(<span class="string">"QUEUE_EMPTY address "</span> + address + <span class="string">" in "</span> + <span class="keyword">this</span>.role);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1712</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1713</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Notify role</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1714</td>  <td class="nbHitsUncovered"><a title="Line 1714: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1714: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1715</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1716</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.role.outputQueueEmpty(address);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1717</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1718</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1719</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> isTransmitting(String address) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1720</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">this</span>.transmitting.contains(address);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1721</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1722</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1723</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Messages</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1724</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1725</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> sendMessage(Message msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1726</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1727</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1728</td>  <td class="nbHitsUncovered"><a title="Line 1728: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1728: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1729</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1730</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Get peer's address; if unknown, use the return address of the message being processed (if any)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1731</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> String peer = msg.getRecipientId();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1732</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        String address = <span class="keyword">this</span>.currentConfig.get(peer);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1733</td>  <td class="nbHitsUncovered"><a title="Line 1733: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1733: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (address == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1734</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            address = <span class="keyword">this</span>.returnAddress;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1735</td>  <td class="nbHitsUncovered"><a title="Line 1735: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1735: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (address == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1736</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"can't send "</span> + msg + <span class="string">" to unknown peer \""</span> + peer + <span class="string">"\""</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1737</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1738</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1739</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1740</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Send message</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1741</td>  <td class="nbHitsUncovered"><a title="Line 1741: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1741: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1742</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.trace(<span class="string">"XMIT "</span> + msg + <span class="string">" to "</span> + address);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1743</td>  <td class="nbHitsUncovered"><a title="Line 1743: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1743: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.network.send(address, msg.encode())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1744</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.transmitting.add(address);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1745</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1746</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1747</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1748</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Transmit failed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1749</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.warn(<span class="string">"transmit of "</span> + msg + <span class="string">" to \""</span> + peer + <span class="string">"\" failed locally"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1750</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1751</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1752</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1753</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> receiveMessage(String address, Message msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1754</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1755</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1756</td>  <td class="nbHitsUncovered"><a title="Line 1756: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1756: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1757</td>  <td class="nbHitsUncovered"><a title="Line 1757: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1757: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1758</td>  <td class="nbHitsUncovered"><a title="Line 1758: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1758: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1759</td>  <td class="nbHitsUncovered"><a title="Line 1759: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1759: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1760</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"rec'd "</span> + msg + <span class="string">" rec'd in shutdown state; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1761</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1762</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1763</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1764</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check cluster ID</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1765</td>  <td class="nbHitsUncovered"><a title="Line 1765: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1765: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (msg.getClusterId() == 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1766</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"rec'd "</span> + msg + <span class="string">" with zero cluster ID from "</span> + address + <span class="string">"; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1767</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1768</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1769</td>  <td class="nbHitsUncovered"><a title="Line 1769: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1769: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">if</span> (<span class="keyword">this</span>.clusterId != 0 &amp;&amp; msg.getClusterId() != <span class="keyword">this</span>.clusterId) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1770</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"rec'd "</span> + msg + <span class="string">" with foreign cluster ID "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1771</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + String.format(<span class="string">"0x%08x"</span>, msg.getClusterId()) + <span class="string">" != "</span> + String.format(<span class="string">"0x%08x"</span>, <span class="keyword">this</span>.clusterId) + <span class="string">"; ignoring"</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1772</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1773</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1774</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1775</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check sender</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1776</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> String peer = msg.getSenderId();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1777</td>  <td class="nbHitsUncovered"><a title="Line 1777: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1777: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (peer.equals(<span class="keyword">this</span>.identity)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1778</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"rec'd "</span> + msg + <span class="string">" from myself (\""</span> + peer + <span class="string">"\", address "</span> + address + <span class="string">"); ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1779</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1780</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1781</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1782</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Sanity check recipient</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1783</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> String dest = msg.getRecipientId();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1784</td>  <td class="nbHitsUncovered"><a title="Line 1784: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1784: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (!dest.equals(<span class="keyword">this</span>.identity)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1785</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"rec'd misdirected "</span> + msg + <span class="string">" intended for \""</span> + dest + <span class="string">"\" from "</span> + address + <span class="string">"; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1786</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1787</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1788</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1789</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Is sender's term too low? Ignore it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1790</td>  <td class="nbHitsUncovered"><a title="Line 1790: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1790: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (msg.getTerm() &lt; <span class="keyword">this</span>.currentTerm) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1791</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg + <span class="string">" with term "</span> + msg.getTerm() + <span class="string">" &lt; "</span> + <span class="keyword">this</span>.currentTerm + <span class="string">" from \""</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1792</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + peer + <span class="string">"\" at "</span> + address + <span class="string">", ignoring"</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1793</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1794</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1795</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1796</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Is my term too low? If so update and revert to follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1797</td>  <td class="nbHitsUncovered"><a title="Line 1797: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1797: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (msg.getTerm() &gt; <span class="keyword">this</span>.currentTerm) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1798</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1799</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// First check with current role; in some special cases we ignore this</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1800</td>  <td class="nbHitsUncovered"><a title="Line 1800: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1800: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.role.mayAdvanceCurrentTerm(msg)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1801</td>  <td class="nbHitsUncovered"><a title="Line 1801: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1801: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1802</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"rec'd "</span> + msg + <span class="string">" with term "</span> + msg.getTerm() + <span class="string">" &gt; "</span> + <span class="keyword">this</span>.currentTerm + <span class="string">" from \""</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1803</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + peer + <span class="string">"\" but current role says to ignore it"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1804</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1805</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1806</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1807</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1808</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Revert to follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1809</td>  <td class="nbHitsUncovered"><a title="Line 1809: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1809: Conditional coverage 0% (0/2).">            <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg.getClass().getSimpleName() + <span class="string">" with term "</span> + msg.getTerm() + <span class="string">" &gt; "</span> + <span class="keyword">this</span>.currentTerm</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1810</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">" from \""</span> + peer + <span class="string">"\", updating term and "</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1811</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (<span class="keyword">this</span>.role <span class="keyword">instanceof</span> FollowerRole ? <span class="string">"remaining a"</span> : <span class="string">"reverting to"</span>) + <span class="string">" follower"</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1812</td>  <td class="nbHitsUncovered"><a title="Line 1812: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1812: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.advanceTerm(msg.getTerm()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1813</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1814</td>  <td class="nbHitsUncovered"><a title="Line 1814: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1814: Conditional coverage 0% (0/2).">            <span class="keyword">this</span>.changeRole(msg.isLeaderMessage() ? <span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>, peer, address) : <span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>));</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1815</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1816</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1817</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1818</td>  <td class="nbHitsUncovered"><a title="Line 1818: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1818: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1819</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.trace(<span class="string">"RECV "</span> + msg + <span class="string">" in "</span> + <span class="keyword">this</span>.role + <span class="string">" from "</span> + address);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1820</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1821</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Handle message</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1822</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.returnAddress = address;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1823</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1824</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            msg.visit(<span class="keyword">this</span>.role);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1825</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">finally</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1826</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.returnAddress = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1827</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1828</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1829</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1830</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Utility methods</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1831</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1832</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">long</span> decodeLong(<span class="keyword">byte</span>[] key, <span class="keyword">long</span> defaultValue) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1833</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> <span class="keyword">byte</span>[] value = <span class="keyword">this</span>.kv.get(key);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1834</td>  <td class="nbHitsUncovered"><a title="Line 1834: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1834: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (value == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1835</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> defaultValue;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1836</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1837</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> LongEncoder.decode(value);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1838</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IllegalArgumentException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1839</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"can't interpret encoded long value "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1840</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + ByteUtil.toString(value) + <span class="string">" under key "</span> + ByteUtil.toString(key), e);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1841</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1842</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1843</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1844</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> String decodeString(<span class="keyword">byte</span>[] key, String defaultValue) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1845</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> <span class="keyword">byte</span>[] value = <span class="keyword">this</span>.kv.get(key);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1846</td>  <td class="nbHitsUncovered"><a title="Line 1846: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1846: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (value == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1847</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> defaultValue;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1848</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> DataInputStream input = <span class="keyword">new</span> DataInputStream(<span class="keyword">new</span> ByteArrayInputStream(value));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1849</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1850</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> input.readUTF();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1851</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1852</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"can't interpret encoded string value "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1853</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + ByteUtil.toString(value) + <span class="string">" under key "</span> + ByteUtil.toString(key), e);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1854</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1855</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1856</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1857</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">byte</span>[] encodeString(String value) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1858</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> ByteArrayOutputStream buf = <span class="keyword">new</span> ByteArrayOutputStream();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1859</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> DataOutputStream output = <span class="keyword">new</span> DataOutputStream(buf);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1860</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1861</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            output.writeUTF(value);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1862</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            output.flush();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1863</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1864</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"unexpected error"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1865</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1866</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> buf.toByteArray();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1867</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1868</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1869</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> Map&lt;String, String&gt; decodeConfig(<span class="keyword">byte</span>[] key) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1870</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> Map&lt;String, String&gt; config = <span class="keyword">new</span> HashMap&lt;&gt;();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1871</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> <span class="keyword">byte</span>[] value = <span class="keyword">this</span>.kv.get(key);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1872</td>  <td class="nbHitsUncovered"><a title="Line 1872: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1872: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (value == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1873</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> config;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1874</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1875</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> DataInputStream data = <span class="keyword">new</span> DataInputStream(<span class="keyword">new</span> ByteArrayInputStream(value));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1876</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">while</span> (<span class="keyword">true</span>) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1877</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                data.mark(1);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1878</td>  <td class="nbHitsUncovered"><a title="Line 1878: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1878: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (data.read() == -1)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1879</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1880</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                data.reset();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1881</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                config.put(data.readUTF(), data.readUTF());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1882</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1883</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1884</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"can't interpret encoded config "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1885</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + ByteUtil.toString(value) + <span class="string">" under key "</span> + ByteUtil.toString(key), e);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1886</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1887</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> config;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1888</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1889</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1890</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">byte</span>[] encodeConfig(Map&lt;String, String&gt; config) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1891</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> ByteArrayOutputStream buf = <span class="keyword">new</span> ByteArrayOutputStream();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1892</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">final</span> DataOutputStream data = <span class="keyword">new</span> DataOutputStream(buf);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1893</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1894</td>  <td class="nbHitsUncovered"><a title="Line 1894: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1894: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Map.Entry&lt;String, String&gt; entry : config.entrySet()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1895</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                data.writeUTF(entry.getKey());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1896</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                data.writeUTF(entry.getValue());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1897</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1898</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            data.flush();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1899</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1900</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"unexpected error"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1901</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1902</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> buf.toByteArray();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1903</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1904</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1905</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Logging</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1906</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1907</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> trace(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1908</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.trace(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg), t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1909</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1910</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1911</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> trace(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1912</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.trace(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1913</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1914</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1915</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> debug(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1916</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.debug(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg), t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1917</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1918</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1919</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> debug(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1920</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.debug(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1921</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1922</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1923</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> info(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1924</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.info(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg), t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1925</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1926</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1927</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> info(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1928</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.info(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1929</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1930</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1931</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> warn(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1932</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.warn(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg), t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1933</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1934</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1935</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> warn(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1936</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.warn(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1937</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1938</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1939</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> error(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1940</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.error(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg), t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1941</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1942</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1943</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> error(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1944</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">this</span>.log.error(String.format(<span class="string">"%s %s: %s"</span>, <span class="keyword">new</span> Timestamp(), <span class="keyword">this</span>.identity, msg));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1945</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1946</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1947</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Raft Roles</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1948</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1949</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">abstract</span> <span class="keyword">static</span> <span class="keyword">class</span> Role <span class="keyword">implements</span> MessageSwitch {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1950</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1951</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> Logger log = LoggerFactory.getLogger(<span class="keyword">this</span>.getClass());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1952</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> RaftKVDatabase raft;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1953</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> Service checkReadyTransactionsService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"check ready transactions"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1954</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1955</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1956</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Role.<span class="keyword">this</span>.checkReadyTransactions();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1957</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1958</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1959</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> Service checkWaitingTransactionsService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"check waiting transactions"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1960</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1961</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1962</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Role.<span class="keyword">this</span>.checkWaitingTransactions();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1963</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1964</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1965</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> Service applyCommittedLogEntriesService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"apply committed logs"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1966</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1967</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1968</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Role.<span class="keyword">this</span>.applyCommittedLogEntries();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1969</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1970</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1971</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1972</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Constructors</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1973</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1974</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> Role(RaftKVDatabase raft) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1975</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft = raft;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1976</td>  <td class="nbHitsUncovered"><a title="Line 1976: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1976: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1977</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1978</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1979</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1980</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1981</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> setup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1982</td>  <td class="nbHitsUncovered"><a title="Line 1982: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1982: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1983</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkReadyTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1984</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkWaitingTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1985</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.applyCommittedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1986</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1987</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1988</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> shutdown() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1989</td>  <td class="nbHitsUncovered"><a title="Line 1989: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1989: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1990</td>  <td class="nbHitsUncovered"><a title="Line 1990: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 1990: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">this</span>.raft.openTransactions.values())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1991</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.cleanupForTransaction(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;1992</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1993</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1994</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1995</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1996</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">abstract</span> <span class="keyword">void</span> outputQueueEmpty(String address);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1997</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;1998</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;1999</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check transactions in the {@link TxState#COMMIT_READY} state to see if we can advance them.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2000</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2001</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> checkReadyTransactions() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2002</td>  <td class="nbHitsUncovered"><a title="Line 2002: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2002: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">new</span> ArrayList&lt;RaftKVTransaction&gt;(<span class="keyword">this</span>.raft.openTransactions.values()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2003</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">new</span> CheckReadyTransactionService(tx).run();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2004</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2005</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2006</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2007</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check transactions in the {@link TxState#COMMIT_WAITING} state to see if they are committed yet.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2008</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * We invoke this service method whenever our {@code commitIndex} advances.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2009</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2010</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> checkWaitingTransactions() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2011</td>  <td class="nbHitsUncovered"><a title="Line 2011: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2011: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">new</span> ArrayList&lt;RaftKVTransaction&gt;(<span class="keyword">this</span>.raft.openTransactions.values()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2012</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">new</span> CheckWaitingTransactionService(tx).run();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2013</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2014</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2015</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2016</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Apply committed but unapplied log entries to the state machine.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2017</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * We invoke this service method whenever log entries are added or our {@code commitIndex} advances.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2018</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2019</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> applyCommittedLogEntries() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2020</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2021</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Apply committed log entries to the state machine</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2022</td>  <td class="nbHitsUncovered"><a title="Line 2022: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2022: Conditional coverage 0% (0/2).">            <span class="keyword">while</span> (<span class="keyword">this</span>.raft.lastAppliedIndex &lt; <span class="keyword">this</span>.raft.commitIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2023</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2024</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Grab the first unwritten log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2025</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LogEntry logEntry = <span class="keyword">this</span>.raft.raftLog.get(0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2026</td>  <td class="nbHitsUncovered"><a title="Line 2026: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2026: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> logEntry.getIndex() == <span class="keyword">this</span>.raft.lastAppliedIndex + 1;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2027</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2028</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Check with subclass</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2029</td>  <td class="nbHitsUncovered"><a title="Line 2029: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2029: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.mayApplyLogEntry(logEntry))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2030</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2031</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2032</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Get the current config as of the log entry we're about to apply</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2033</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> HashMap&lt;String, String&gt; logEntryConfig = <span class="keyword">new</span> HashMap&lt;&gt;(<span class="keyword">this</span>.raft.lastAppliedConfig);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2034</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                logEntry.applyConfigChange(logEntryConfig);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2035</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2036</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Prepare combined Mutations containing prefixed log entry changes plus my own</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2037</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Writes logWrites = logEntry.getWrites();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2038</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Writes myWrites = <span class="keyword">new</span> Writes();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2039</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                myWrites.getPuts().put(LAST_APPLIED_TERM_KEY, LongEncoder.encode(logEntry.getTerm()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2040</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                myWrites.getPuts().put(LAST_APPLIED_INDEX_KEY, LongEncoder.encode(logEntry.getIndex()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2041</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                myWrites.getPuts().put(LAST_APPLIED_CONFIG_KEY, <span class="keyword">this</span>.raft.encodeConfig(logEntryConfig));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2042</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Mutations mutations = <span class="keyword">new</span> Mutations() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2043</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2044</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2045</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">public</span> Iterable&lt;KeyRange&gt; getRemoveRanges() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2046</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span> Iterables.transform(logWrites.getRemoveRanges(), <span class="keyword">new</span> PrefixKeyRangeFunction(STATE_MACHINE_PREFIX));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2047</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2048</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2049</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2050</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">public</span> Iterable&lt;Map.Entry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt;&gt; getPutPairs() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2051</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span> Iterables.concat(</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2052</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                          Iterables.transform(logWrites.getPutPairs(), <span class="keyword">new</span> PrefixPutFunction(STATE_MACHINE_PREFIX)),</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2053</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                          myWrites.getPutPairs());</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2054</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2055</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2056</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2057</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">public</span> Iterable&lt;Map.Entry&lt;<span class="keyword">byte</span>[], Long&gt;&gt; getAdjustPairs() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2058</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span> Iterables.transform(logWrites.getAdjustPairs(), <span class="keyword">new</span> PrefixAdjustFunction(STATE_MACHINE_PREFIX));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2059</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2060</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                };</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2061</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2062</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Apply updates to the key/value store (durably); prefix all transaction keys with STATE_MACHINE_PREFIX</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2063</td>  <td class="nbHitsUncovered"><a title="Line 2063: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2063: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2064</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"applying committed log entry "</span> + logEntry + <span class="string">" to key/value store"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2065</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2066</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.kv.mutate(mutations, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2067</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2068</td>  <td class="nbHitsUncovered"><a title="Line 2068: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2068: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                    <span class="keyword">if</span> (e <span class="keyword">instanceof</span> RuntimeException &amp;&amp; e.getCause() <span class="keyword">instanceof</span> IOException)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2069</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        e = (IOException)e.getCause();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2070</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"error applying log entry "</span> + logEntry + <span class="string">" to key/value store"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2071</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2072</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2073</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2074</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Update in-memory state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2075</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.lastAppliedTerm = logEntry.getTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2076</td>  <td class="nbHitsUncovered"><a title="Line 2076: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2076: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> logEntry.getIndex() == <span class="keyword">this</span>.raft.lastAppliedIndex + 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2077</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.lastAppliedIndex = logEntry.getIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2078</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                logEntry.applyConfigChange(<span class="keyword">this</span>.raft.lastAppliedConfig);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2079</td>  <td class="nbHitsUncovered"><a title="Line 2079: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2079: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> <span class="keyword">this</span>.raft.currentConfig.equals(<span class="keyword">this</span>.raft.buildCurrentConfig());</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2080</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2081</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Delete the log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2082</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.raftLog.remove(0);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2083</td>  <td class="nbHitsUncovered"><a title="Line 2083: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2083: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!logEntry.getFile().delete())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2084</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"failed to delete log file "</span> + logEntry.getFile());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2085</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2086</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Subclass hook</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2087</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.logEntryApplied(logEntry);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2088</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2089</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2090</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2091</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2092</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Determine whether the given log entry may be applied to the state machine.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2093</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2094</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">boolean</span> mayApplyLogEntry(LogEntry logEntry) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2095</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2096</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2097</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2098</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2099</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Subclass hook invoked after a log entry has been applied to the state machine.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2100</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2101</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> logEntryApplied(LogEntry logEntry) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2102</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2103</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2104</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Transaction service classes</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2105</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2106</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">abstract</span> <span class="keyword">class</span> AbstractTransactionService <span class="keyword">extends</span> Service {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2107</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2108</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">protected</span> <span class="keyword">final</span> RaftKVTransaction tx;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2109</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2110</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            AbstractTransactionService(RaftKVTransaction tx, String desc) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2111</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">super</span>(Role.<span class="keyword">this</span>, desc);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2112</td>  <td class="nbHitsUncovered"><a title="Line 2112: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2112: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> tx != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2113</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.tx = tx;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2114</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2115</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2117</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2118</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2119</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.doRun();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2120</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (KVTransactionException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2121</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Role.<span class="keyword">this</span>.raft.fail(tx, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2122</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2123</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Role.<span class="keyword">this</span>.raft.fail(tx, <span class="keyword">new</span> KVTransactionException(tx, e));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2124</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2125</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2126</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2127</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">protected</span> <span class="keyword">abstract</span> <span class="keyword">void</span> doRun();</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2128</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2129</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2130</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">boolean</span> equals(Object obj) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2131</td>  <td class="nbHitsUncovered"><a title="Line 2131: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2131: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (obj == <span class="keyword">null</span> || obj.getClass() != <span class="keyword">this</span>.getClass())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2132</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2133</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> AbstractTransactionService that = (AbstractTransactionService)obj;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2134</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.tx.equals(that.tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2135</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2136</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2137</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">int</span> hashCode() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2139</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.tx.hashCode();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2141</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2142</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">class</span> CheckReadyTransactionService <span class="keyword">extends</span> AbstractTransactionService {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2145</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            CheckReadyTransactionService(RaftKVTransaction tx) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2146</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">super</span>(tx, <span class="string">"check ready tx#"</span> + tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2147</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2148</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2149</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2150</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">protected</span> <span class="keyword">void</span> doRun() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2151</td>  <td class="nbHitsUncovered"><a title="Line 2151: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2151: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.tx.getState().equals(TxState.COMMIT_READY))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2152</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Role.<span class="keyword">this</span>.checkReadyTransaction(<span class="keyword">this</span>.tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2153</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">class</span> CheckWaitingTransactionService <span class="keyword">extends</span> AbstractTransactionService {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2157</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2158</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            CheckWaitingTransactionService(RaftKVTransaction tx) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2159</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">super</span>(tx, <span class="string">"check waiting tx#"</span> + tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2160</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2161</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2162</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2163</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">protected</span> <span class="keyword">void</span> doRun() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2164</td>  <td class="nbHitsUncovered"><a title="Line 2164: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2164: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.tx.getState().equals(TxState.COMMIT_WAITING))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2165</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Role.<span class="keyword">this</span>.checkWaitingTransaction(<span class="keyword">this</span>.tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2166</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2167</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2168</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2169</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Transactions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2170</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2171</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2172</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check a transaction that is ready to be committed (in the {@link TxState#COMMIT_READY} state).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2173</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2174</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2175</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2176</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2177</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After changing roles&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2178</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a transaction has entered the {@link TxState#COMMIT_READY} state&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2179</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After the leader is newly known (in {@link FollowerRole})&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2180</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After the leader's output queue goes from non-empty to empty (in {@link FollowerRole})&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2181</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After the leader's {@code commitIndex} has advanced, in case a config change transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2182</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      is waiting on a previous config change transaction (in {@link LeaderRole})&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2183</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2184</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2185</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param tx the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2186</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws KVTransactionException if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2187</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2188</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">abstract</span> <span class="keyword">void</span> checkReadyTransaction(RaftKVTransaction tx);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2189</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2190</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2191</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check a transaction waiting for its log entry to be committed (in the {@link TxState#COMMIT_WAITING} state).</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2192</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2193</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2194</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2195</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2196</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After changing roles&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2197</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a transaction has entered the {@link TxState#COMMIT_WAITING} state&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2198</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After advancing my {@code commitIndex} (as leader or follower)&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2199</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After receiving an updated {@linkplain AppendResponse#getLeaderLeaseTimeout leader lease timeout}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2200</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      (in {@link FollowerRole})&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2201</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2202</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2203</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param tx the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2204</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @throws KVTransactionException if an error occurs</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2205</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2206</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> checkWaitingTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2207</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2208</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle the case the transaction's committed log index has already been applied to the state machine</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2209</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> commitIndex = tx.getCommitIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2210</td>  <td class="nbHitsUncovered"><a title="Line 2210: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2210: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (commitIndex &lt; <span class="keyword">this</span>.raft.lastAppliedIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2211</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2212</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// This can happen if we lose contact and by the time we're back the log entry has</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2213</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// already been applied to the state machine on some leader and that leader sent</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2214</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// use an InstallSnapshot message. We don't know whether it actually got committed</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2215</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// or not, so the transaction must be retried.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2216</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"committed log entry was missed"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2217</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2218</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2219</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Has the transaction's log entry been received yet?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2220</td>  <td class="nbHitsUncovered"><a title="Line 2220: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2220: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (commitIndex &gt; <span class="keyword">this</span>.raft.getLastLogIndex())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2221</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2222</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2223</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Has the transaction's log entry been committed yet?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2224</td>  <td class="nbHitsUncovered"><a title="Line 2224: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2224: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (commitIndex &gt; <span class="keyword">this</span>.raft.commitIndex)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2225</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2226</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2227</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Verify the term of the committed log entry; if not what we expect, the log entry was overwritten by a new leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2228</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> commitTerm = tx.getCommitTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2229</td>  <td class="nbHitsUncovered"><a title="Line 2229: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2229: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.raft.getLogTermAtIndex(commitIndex) != commitTerm)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2230</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"leader was deposed during commit and transaction's log entry overwritten"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2231</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2232</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check with subclass</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2233</td>  <td class="nbHitsUncovered"><a title="Line 2233: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2233: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.mayCommit(tx))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2234</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2235</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2236</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Transaction is officially committed now</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2237</td>  <td class="nbHitsUncovered"><a title="Line 2237: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2237: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2238</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.trace(<span class="string">"commit successful for "</span> + tx + <span class="string">" (commit index "</span> + <span class="keyword">this</span>.raft.commitIndex + <span class="string">" &gt;= "</span> + commitIndex + <span class="string">")"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2239</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.succeed(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2240</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2241</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2242</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">boolean</span> mayCommit(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2243</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2244</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2245</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2246</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2247</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Perform any role-specific transaction cleanups.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2248</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2249</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2250</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Invoked either when transaction is closed or this role is being shutdown.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2251</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2252</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param tx the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2253</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2254</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">abstract</span> <span class="keyword">void</span> cleanupForTransaction(RaftKVTransaction tx);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2255</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2256</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2257</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check a transaction that is ready to be committed (in the {@link TxState#COMMIT_READY} state) for snapshot isolation.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2258</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2259</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param tx the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2260</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return true if snapshot isolation and moved to {@link TxState@COMMIT_WAITING}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2261</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2262</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">boolean</span> checkReadyTransactionReadOnlySnapshot(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2263</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2264</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2265</td>  <td class="nbHitsUncovered"><a title="Line 2265: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2265: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2266</td>  <td class="nbHitsUncovered"><a title="Line 2266: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2266: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2267</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2268</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check isolation</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2269</td>  <td class="nbHitsUncovered"><a title="Line 2269: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2269: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!tx.isReadOnlySnapshot())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2270</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2271</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2272</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// For snapshot isolation, we only need to wait for the commit of the transaction's base log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2273</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.setCommitTerm(tx.getBaseTerm());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2274</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.setCommitIndex(tx.getBaseIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2275</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.setState(TxState.COMMIT_WAITING);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2276</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> CheckWaitingTransactionService(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2277</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2278</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2279</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2280</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2281</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2282</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Messages</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2283</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2284</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">boolean</span> mayAdvanceCurrentTerm(Message msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2285</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2286</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2287</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2288</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> failUnexpectedMessage(Message msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2289</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.warn(<span class="string">"rec'd unexpected message "</span> + msg + <span class="string">" while in role "</span> + <span class="keyword">this</span> + <span class="string">"; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2290</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2291</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2292</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2293</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2294</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">boolean</span> checkState() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2295</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2296</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2297</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2298</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Logging</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2299</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2300</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> trace(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2301</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.trace(msg, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2302</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2303</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2304</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> trace(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2305</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.trace(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2306</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2307</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2308</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> debug(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2309</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.debug(msg, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2310</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2311</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2312</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> debug(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2313</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.debug(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2314</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2315</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2316</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> info(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2317</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.info(msg, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2318</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2319</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2320</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> info(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2321</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.info(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2322</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2323</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2324</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> warn(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2325</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.warn(msg, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2326</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2327</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2328</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> warn(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2329</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.warn(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2330</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2331</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2332</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> error(String msg, Throwable t) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2333</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.error(msg, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2334</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2335</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2336</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> error(String msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2337</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.error(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2338</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2339</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2340</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2341</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2342</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2343</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">abstract</span> String toString();</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2344</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2345</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> String toStringPrefix() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2346</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.getClass().getSimpleName()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2347</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"[term="</span> + <span class="keyword">this</span>.raft.currentTerm</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2348</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">",applied="</span> + <span class="keyword">this</span>.raft.lastAppliedTerm + <span class="string">"/"</span> + <span class="keyword">this</span>.raft.lastAppliedIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2349</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">",commit="</span> + <span class="keyword">this</span>.raft.commitIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2350</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">",log="</span> + <span class="keyword">this</span>.raft.raftLog</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2351</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"]"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2352</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2353</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2354</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2355</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// LEADER role</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2356</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2357</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> LeaderRole <span class="keyword">extends</span> Role {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2358</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2359</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> ArrayList&lt;LogEntry&gt; appliedLogEntries = <span class="keyword">new</span> ArrayList&lt;&gt;(); <span class="comment">// log entries already applied to key/value store</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2360</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> HashMap&lt;String, Follower&gt; followerMap = <span class="keyword">new</span> HashMap&lt;&gt;();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2361</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Service updateLeaderCommitIndexService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"update leader commitIndex"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2362</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2363</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2364</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LeaderRole.<span class="keyword">this</span>.updateLeaderCommitIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2365</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2366</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2367</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Service pruneAppliedLogEntriesService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"prune applied logs"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2368</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2369</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2370</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LeaderRole.<span class="keyword">this</span>.pruneAppliedLogEntries();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2371</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2372</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2373</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Service updateLeaseTimeoutService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"update lease timeout"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2374</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2375</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2376</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LeaderRole.<span class="keyword">this</span>.updateLeaseTimeout();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2377</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2378</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2379</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> Service updateKnownFollowersService = <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"update known followers"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2380</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2381</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2382</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LeaderRole.<span class="keyword">this</span>.updateKnownFollowers();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2383</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2384</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        };</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2385</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> Timestamp leaseTimeout = <span class="keyword">new</span> Timestamp();                   <span class="comment">// tracks the earliest time we can be deposed</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2386</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2387</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Constructors</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2388</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2389</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> LeaderRole(RaftKVDatabase raft) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2390</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(raft);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2391</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2392</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2393</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2394</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2395</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2396</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> setup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2397</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.setup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2398</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"entering leader role in term "</span> + <span class="keyword">this</span>.raft.currentTerm);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2399</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2400</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Generate follower list</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2401</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.updateKnownFollowers();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2402</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2403</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Append a "dummy" log entry with my current term. This allows us to advance the commit index when the last</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2404</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// entry in our log is from a prior term. This is needed to avoid the problem where a transaction could end up</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2405</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// waiting indefinitely for its log entry with a prior term number to be committed.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2406</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">final</span> LogEntry logEntry;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2407</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2408</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                logEntry = <span class="keyword">this</span>.applyNewLogEntry(<span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(<span class="keyword">new</span> LogEntry.Data(<span class="keyword">new</span> Writes(), <span class="keyword">null</span>)));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2409</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2410</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.error(<span class="string">"error attempting to apply initial log entry"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2411</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2412</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2413</td>  <td class="nbHitsUncovered"><a title="Line 2413: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2413: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2414</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"added log entry "</span> + logEntry + <span class="string">" to commit at the beginning of my new term"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2415</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2416</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2417</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2418</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> shutdown() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2419</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.shutdown();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2420</td>  <td class="nbHitsUncovered"><a title="Line 2420: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2420: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2421</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2422</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2423</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2424</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2425</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2426</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2427</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> outputQueueEmpty(String address) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2428</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2429</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Find matching follower(s) and update them if needed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2430</td>  <td class="nbHitsUncovered"><a title="Line 2430: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2430: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2431</td>  <td class="nbHitsUncovered"><a title="Line 2431: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2431: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (follower.getAddress().equals(address)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2432</td>  <td class="nbHitsUncovered"><a title="Line 2432: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2432: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2433</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.trace(<span class="string">"updating peer \""</span> + follower.getIdentity() + <span class="string">"\" after queue empty notification"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2434</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> UpdateFollowerService(follower));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2435</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2436</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2437</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2438</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2439</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2440</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> logEntryApplied(LogEntry logEntry) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2441</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2442</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Save log entry in the applied log entry list</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2443</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.appliedLogEntries.add(logEntry);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2444</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2445</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Prune applied log entries</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2446</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.pruneAppliedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2447</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2448</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2449</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2450</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">boolean</span> mayApplyLogEntry(LogEntry logEntry) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2451</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2452</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Are we running out of memory? If so, go ahead.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2453</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> memoryUsed = <span class="keyword">this</span>.pruneAppliedLogEntries();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2454</td>  <td class="nbHitsUncovered"><a title="Line 2454: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2454: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (memoryUsed &gt; <span class="keyword">this</span>.raft.maxAppliedLogMemory) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2455</td>  <td class="nbHitsUncovered"><a title="Line 2455: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2455: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2456</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"allowing log entry "</span> + logEntry + <span class="string">" to be applied because memory usage is high: "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2457</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + memoryUsed + <span class="string">" &gt; "</span> + <span class="keyword">this</span>.raft.maxAppliedLogMemory);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2458</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2459</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2460</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2461</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2462</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If any snapshots are in progress, we don't want to apply any log entries with index greater than the snapshot's</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2463</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// index, because then we'd "lose" the ability to update the follower with that log entry, and as a result just have</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2464</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// to send a snapshot again. However, we impose a limit on how long we'll wait for a slow follower.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2465</td>  <td class="nbHitsUncovered"><a title="Line 2465: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2465: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2466</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> SnapshotTransmit snapshotTransmit = follower.getSnapshotTransmit();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2467</td>  <td class="nbHitsUncovered"><a title="Line 2467: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2467: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">if</span> (snapshotTransmit != <span class="keyword">null</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2468</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  &amp;&amp; snapshotTransmit.getSnapshotIndex() &lt; logEntry.getIndex()              <span class="comment">// currently, this will always be true</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2469</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  &amp;&amp; snapshotTransmit.getAge() &lt; MAX_SNAPSHOT_TRANSMIT_AGE) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2470</td>  <td class="nbHitsUncovered"><a title="Line 2470: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2470: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2471</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.trace(<span class="string">"delaying application of "</span> + logEntry + <span class="string">" because of in-progress snapshot install of "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2472</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                          + snapshotTransmit.getSnapshotTerm() + <span class="string">"/"</span> + snapshotTransmit.getSnapshotIndex()</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2473</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                          + <span class="string">" to "</span> + follower);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2474</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2475</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2476</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2477</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2478</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2479</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If some follower does not yet have the log entry, wait for them to get it (up to some maximum time)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2480</td>  <td class="nbHitsUncovered"><a title="Line 2480: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2480: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (logEntry.getAge() &lt; MAX_SLOW_FOLLOWER_APPLY_DELAY_HEARTBEATS * <span class="keyword">this</span>.raft.heartbeatTimeout) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2481</td>  <td class="nbHitsUncovered"><a title="Line 2481: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2481: Conditional coverage 0% (0/2).">                <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2482</td>  <td class="nbHitsUncovered"><a title="Line 2482: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2482: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (follower.getMatchIndex() &lt; logEntry.getIndex()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2483</td>  <td class="nbHitsUncovered"><a title="Line 2483: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2483: Conditional coverage 0% (0/2).">                        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2484</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            <span class="keyword">this</span>.trace(<span class="string">"delaying application of "</span> + logEntry + <span class="string">" (age "</span> + logEntry.getAge()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2485</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                              + <span class="string">" &lt; "</span> + (MAX_SLOW_FOLLOWER_APPLY_DELAY_HEARTBEATS * <span class="keyword">this</span>.raft.heartbeatTimeout)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2486</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                              + <span class="string">") because of slow "</span> + follower);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2487</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2488</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2489</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2490</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2491</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2492</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2493</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// OK</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2494</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2495</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2496</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2497</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2498</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check memory usage for both unapplied and applied log entries, and discard already-applied log entries as appropriate</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2499</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * to stay under the memory limits.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2500</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2501</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2502</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2503</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2504</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a log entry has been added to the log&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2505</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a log entry has been applied to the state machine&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2506</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2507</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2508</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return total applied log entry memory used (approximate)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2509</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2510</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">long</span> pruneAppliedLogEntries() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2511</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2512</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Calculate total memory usage</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2513</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">long</span> totalLogEntryMemoryUsed = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2514</td>  <td class="nbHitsUncovered"><a title="Line 2514: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2514: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (LogEntry logEntry : Iterables.concat(<span class="keyword">this</span>.appliedLogEntries, <span class="keyword">this</span>.raft.raftLog))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2515</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                totalLogEntryMemoryUsed += logEntry.getFileSize();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2516</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2517</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Delete applied log entries to stay under limits</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2518</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">long</span> numAppliedLogEntries = <span class="keyword">this</span>.appliedLogEntries.size();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2519</td>  <td class="nbHitsUncovered"><a title="Line 2519: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2519: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Iterator&lt;LogEntry&gt; i = <span class="keyword">this</span>.appliedLogEntries.iterator(); i.hasNext(); ) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2520</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LogEntry logEntry = i.next();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2521</td>  <td class="nbHitsUncovered"><a title="Line 2521: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2521: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">if</span> (logEntry.getAge() &gt;= <span class="keyword">this</span>.raft.maxTransactionDuration</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2522</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  || totalLogEntryMemoryUsed &gt; <span class="keyword">this</span>.raft.maxAppliedLogMemory</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2523</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  || numAppliedLogEntries &gt; MAX_APPLIED_LOG_ENTRIES) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2524</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    i.remove();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2525</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    totalLogEntryMemoryUsed -= logEntry.getFileSize();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2526</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    numAppliedLogEntries--;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2527</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2528</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2529</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2530</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2531</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> totalLogEntryMemoryUsed;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2532</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2533</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2534</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2535</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Update my {@code commitIndex} based on followers' {@code matchIndex}'s.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2536</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2537</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2538</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2539</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2540</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After any log entry has been added to the log, if we have zero followers&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2541</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a log entry that contains a configuration change has been added to the log&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2542</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a follower's {@linkplain Follower#getMatchIndex match index} has advanced&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2543</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2544</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2545</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateLeaderCommitIndex() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2546</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2547</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update my commit index based on when a majority of cluster members have ack'd log entries</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2548</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> lastLogIndex = <span class="keyword">this</span>.raft.getLastLogIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2549</td>  <td class="nbHitsUncovered"><a title="Line 2549: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2549: Conditional coverage 0% (0/2).">            <span class="keyword">while</span> (<span class="keyword">this</span>.raft.commitIndex &lt; lastLogIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2550</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2551</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Get the index in question</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2552</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> index = <span class="keyword">this</span>.raft.commitIndex + 1;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2553</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2554</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Count the number of nodes which have a copy of the log entry at index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2555</td>  <td class="nbHitsUncovered"><a title="Line 2555: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2555: Conditional coverage 0% (0/2).">                <span class="keyword">int</span> numVotes = <span class="keyword">this</span>.raft.isClusterMember() ? 1 : 0;                         <span class="comment">// count myself, if member</span></a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2556</td>  <td class="nbHitsUncovered"><a title="Line 2556: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2556: Conditional coverage 0% (0/2).">                <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {                       <span class="comment">// count followers who are members</span></a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2557</td>  <td class="nbHitsUncovered"><a title="Line 2557: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2557: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                    <span class="keyword">if</span> (follower.getMatchIndex() &gt;= index &amp;&amp; <span class="keyword">this</span>.raft.isClusterMember(follower.getIdentity()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2558</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        numVotes++;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2559</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2560</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2561</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Do a majority of cluster nodes have a copy of this log entry?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2562</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">int</span> majority = <span class="keyword">this</span>.raft.currentConfig.size() / 2 + 1;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2563</td>  <td class="nbHitsUncovered"><a title="Line 2563: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2563: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (numVotes &lt; majority)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2564</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2565</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2566</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Log entry term must match my current term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2567</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LogEntry logEntry = <span class="keyword">this</span>.raft.getLogEntryAtIndex(index);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2568</td>  <td class="nbHitsUncovered"><a title="Line 2568: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2568: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (logEntry.getTerm() != <span class="keyword">this</span>.raft.currentTerm)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2569</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2570</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2571</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Update commit index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2572</td>  <td class="nbHitsUncovered"><a title="Line 2572: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2572: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2573</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"advancing commit index from "</span> + <span class="keyword">this</span>.raft.commitIndex + <span class="string">" -&gt; "</span> + index</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2574</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">" based on "</span> + numVotes + <span class="string">"/"</span> + <span class="keyword">this</span>.raft.currentConfig.size() + <span class="string">" nodes having received "</span> + logEntry);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2575</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2576</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.commitIndex = index;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2577</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2578</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Perform various service</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2579</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkReadyTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2580</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkWaitingTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2581</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.applyCommittedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2582</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2583</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Notify all followers with the updated leaderCommit</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2584</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.updateAllFollowersNow();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2585</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2586</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2587</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If we are no longer a member of our cluster, step down as leader after the latest config change is committed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2588</td>  <td class="nbHitsUncovered"><a title="Line 2588: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2588: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.isClusterMember()</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2589</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              &amp;&amp; <span class="keyword">this</span>.raft.commitIndex &gt;= <span class="keyword">this</span>.findMostRecentConfigChangeMatching(Predicates.&lt;String[]&gt;alwaysTrue())) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2590</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.log.info(<span class="string">"stepping down as leader of cluster (no longer a member)"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2591</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>.raft));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2592</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2593</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2594</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2595</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2596</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Update my {@code leaseTimeout} based on followers' returned {@code leaderTimeout}'s.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2597</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2598</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2599</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2600</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2601</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a follower has replied with an {@link AppendResponse} containing a newer</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2602</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      {@linkplain AppendResponse#getLeaderTimestamp leader timestamp} than before&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2603</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2604</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2605</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateLeaseTimeout() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2606</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2607</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Only needed when we have followers</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2608</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">int</span> numFollowers = <span class="keyword">this</span>.followerMap.size();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2609</td>  <td class="nbHitsUncovered"><a title="Line 2609: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2609: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (numFollowers == 0)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2610</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2611</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2612</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Get all cluster member leader timestamps, sorted in increasing order</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2613</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Timestamp[] leaderTimestamps = <span class="keyword">new</span> Timestamp[<span class="keyword">this</span>.raft.currentConfig.size()];</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2614</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">int</span> index = 0;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2615</td>  <td class="nbHitsUncovered"><a title="Line 2615: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2615: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.raft.isClusterMember())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2616</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                leaderTimestamps[index++] = <span class="keyword">new</span> Timestamp();                                <span class="comment">// only matters in single node cluster</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2617</td>  <td class="nbHitsUncovered"><a title="Line 2617: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2617: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2618</td>  <td class="nbHitsUncovered"><a title="Line 2618: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2618: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.raft.isClusterMember(follower.getIdentity()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2619</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    leaderTimestamps[index++] = follower.getLeaderTimestamp();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2620</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2621</td>  <td class="nbHitsUncovered"><a title="Line 2621: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2621: Conditional coverage 0% (0/2).">            Preconditions.checkArgument(index == leaderTimestamps.length);                  <span class="comment">// sanity check</span></a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2622</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            Arrays.sort(leaderTimestamps);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2623</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2624</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2625</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Calculate highest leaderTimeout shared by a majority of cluster members, based on sorted array:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2626</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2627</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//  # nodes    timestamps</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2628</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//  -------    ----------</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2629</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//     5       [ ][ ][x][x][x]        3/5 x's make a majority at index (5 - 1)/2 = 2</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2630</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//     6       [ ][ ][x][x][x][x]     4/6 x's make a majority at index (6 - 1)/2 = 2</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2631</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2632</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// The minimum leaderTimeout shared by a majority of nodes is at index (leaderTimestamps.length - 1) / 2.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2633</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// We then add the minimum election timeout, then subtract a little for clock drift.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2634</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">//</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2635</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Timestamp newLeaseTimeout = leaderTimestamps[(leaderTimestamps.length + 1) / 2]</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2636</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              .offset((<span class="keyword">int</span>)(<span class="keyword">this</span>.raft.minElectionTimeout * (1.0f - MAX_CLOCK_DRIFT)));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2637</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2638</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Immediately notify any followers who are waiting on this updated timestamp (or any smaller timestamp)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2639</td>  <td class="nbHitsUncovered"><a title="Line 2639: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2639: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (newLeaseTimeout.compareTo(<span class="keyword">this</span>.leaseTimeout) &gt; 0) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2640</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2641</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Update my leader lease timeout</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2642</td>  <td class="nbHitsUncovered"><a title="Line 2642: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2642: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2643</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"updating my lease timeout from "</span> + <span class="keyword">this</span>.leaseTimeout + <span class="string">" -&gt; "</span> + newLeaseTimeout);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2644</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.leaseTimeout = newLeaseTimeout;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2645</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2646</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Notify any followers who care</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2647</td>  <td class="nbHitsUncovered"><a title="Line 2647: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2647: Conditional coverage 0% (0/2).">                <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2648</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">final</span> NavigableSet&lt;Timestamp&gt; timeouts = follower.getCommitLeaseTimeouts().headSet(<span class="keyword">this</span>.leaseTimeout, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2649</td>  <td class="nbHitsUncovered"><a title="Line 2649: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2649: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (!timeouts.isEmpty()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2650</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        follower.updateNow();                           <span class="comment">// notify follower so it can commit waiting transaction(s)</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2651</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        timeouts.clear();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2652</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2653</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2654</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2655</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2656</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2657</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2658</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Update our list of followers to match our current configuration.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2659</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2660</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2661</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2662</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2663</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a log entry that contains a configuration change has been added to the log&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2664</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;When the {@linkplain Follower#getNextIndex next index} of a follower not in the current config advances&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2665</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2666</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2667</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateKnownFollowers() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2668</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2669</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Compare known followers with the current config and determine who needs to be be added or removed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2670</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> HashSet&lt;String&gt; adds = <span class="keyword">new</span> HashSet&lt;&gt;(<span class="keyword">this</span>.raft.currentConfig.keySet());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2671</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            adds.removeAll(<span class="keyword">this</span>.followerMap.keySet());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2672</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            adds.remove(<span class="keyword">this</span>.raft.identity);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2673</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> HashSet&lt;String&gt; dels = <span class="keyword">new</span> HashSet&lt;&gt;(<span class="keyword">this</span>.followerMap.keySet());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2674</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            dels.removeAll(<span class="keyword">this</span>.raft.currentConfig.keySet());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2675</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2676</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Keep around a follower after its removal until it receives the config change that removed it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2677</td>  <td class="nbHitsUncovered"><a title="Line 2677: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2677: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2678</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2679</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Is this follower scheduled for deletion?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2680</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> String peer = follower.getIdentity();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2681</td>  <td class="nbHitsUncovered"><a title="Line 2681: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2681: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!dels.contains(peer))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2682</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">continue</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2683</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2684</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Find the most recent log entry containing a config change in which the follower was removed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2685</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> String node = follower.getIdentity();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2686</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> index = <span class="keyword">this</span>.findMostRecentConfigChangeMatching(<span class="keyword">new</span> Predicate&lt;String[]&gt;() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2687</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2688</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">public</span> <span class="keyword">boolean</span> apply(String[] configChange) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2689</td>  <td class="nbHitsUncovered"><a title="Line 2689: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2689: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                        <span class="keyword">return</span> configChange[0].equals(node) &amp;&amp; configChange[1] == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2690</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2691</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                });</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2692</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2693</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// If follower has not received that log entry yet, keep on updating them until they do</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2694</td>  <td class="nbHitsUncovered"><a title="Line 2694: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2694: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (follower.getMatchIndex() &lt; index)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2695</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    dels.remove(peer);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2696</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2697</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2698</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Add new followers</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2699</td>  <td class="nbHitsUncovered"><a title="Line 2699: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2699: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (String peer : adds) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2700</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> String address = <span class="keyword">this</span>.raft.currentConfig.get(peer);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2701</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Follower follower = <span class="keyword">new</span> Follower(peer, address, <span class="keyword">this</span>.raft.getLastLogIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2702</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"adding new follower \""</span> + peer + <span class="string">"\" at "</span> + address);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2703</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setUpdateTimer(</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2704</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.<span class="keyword">new</span> Timer(<span class="string">"update timer for \""</span> + peer + <span class="string">"\""</span>, <span class="keyword">new</span> UpdateFollowerService(follower)));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2705</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.followerMap.put(peer, follower);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2706</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.updateNow();                                               <span class="comment">// schedule an immediate update</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2707</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2708</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2709</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Remove old followers</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2710</td>  <td class="nbHitsUncovered"><a title="Line 2710: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2710: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (String peer : dels) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2711</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Follower follower = <span class="keyword">this</span>.followerMap.remove(peer);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2712</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"removing old follower \""</span> + peer + <span class="string">"\""</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2713</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2714</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2715</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2716</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2717</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2718</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check whether a follower needs an update and send one if so.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2719</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2720</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2721</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2722</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2723</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a new follower has been added&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2724</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;When the output queue for a follower goes from non-empty to empty&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2725</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After the follower's {@linkplain Follower#getUpdateTimer update timer} has expired&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2726</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a new log entry has been added to the log (all followers)&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2727</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After receiving an {@link AppendResponse} that caused the follower's</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2728</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      {@linkplain Follower#getNextIndex next index} to change&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2729</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After receiving the first positive {@link AppendResponse} to a probe&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2730</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After our {@code commitIndex} has advanced (all followers)&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2731</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After our {@code leaseTimeout} has advanced past one or more of a follower's</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2732</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      {@linkplain Follower#getCommitLeaseTimeouts commit lease timeouts} (with update timer reset)&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2733</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After sending a {@link CommitResponse} with a non-null {@linkplain CommitResponse#getCommitLeaderLeaseTimeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2734</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *      commit leader lease timeout} (all followers) to probe for updated leader timestamps&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2735</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After starting, aborting, or completing a snapshot install for a follower&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2736</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2737</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2738</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateFollower(Follower follower) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2739</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2740</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If follower has an in-progress snapshot that has become too stale, abort it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2741</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String peer = follower.getIdentity();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2742</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            SnapshotTransmit snapshotTransmit = follower.getSnapshotTransmit();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2743</td>  <td class="nbHitsUncovered"><a title="Line 2743: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2743: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (snapshotTransmit != <span class="keyword">null</span> &amp;&amp; snapshotTransmit.getSnapshotIndex() &lt; <span class="keyword">this</span>.raft.lastAppliedIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2744</td>  <td class="nbHitsUncovered"><a title="Line 2744: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2744: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2745</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"aborting stale snapshot install for "</span> + follower);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2746</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.cancelSnapshotTransmit();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2747</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.updateNow();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2748</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2749</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2750</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Is follower's queue empty? If not, hold off until then</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2751</td>  <td class="nbHitsUncovered"><a title="Line 2751: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2751: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.raft.isTransmitting(follower.getAddress())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2752</td>  <td class="nbHitsUncovered"><a title="Line 2752: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2752: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2753</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"no update for \""</span> + peer + <span class="string">"\": output queue still not empty"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2754</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2755</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2756</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2757</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle any in-progress snapshot install</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2758</td>  <td class="nbHitsUncovered"><a title="Line 2758: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2758: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> ((snapshotTransmit = follower.getSnapshotTransmit()) != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2759</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2760</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Send the next chunk in transmission, if any</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2761</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> pairIndex = snapshotTransmit.getPairIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2762</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> ByteBuffer chunk = snapshotTransmit.getNextChunk();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2763</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">boolean</span> synced = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2764</td>  <td class="nbHitsUncovered"><a title="Line 2764: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2764: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (chunk != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2765</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2766</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Send next chunk</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2767</td>  <td class="nbHitsUncovered"><a title="Line 2767: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2767: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                    <span class="keyword">final</span> InstallSnapshot msg = <span class="keyword">new</span> InstallSnapshot(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, peer,</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2768</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      <span class="keyword">this</span>.raft.currentTerm, snapshotTransmit.getSnapshotTerm(), snapshotTransmit.getSnapshotIndex(), pairIndex,</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2769</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      pairIndex == 0 ? snapshotTransmit.getSnapshotConfig() : <span class="keyword">null</span>, !snapshotTransmit.hasMoreChunks(), chunk);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2770</td>  <td class="nbHitsUncovered"><a title="Line 2770: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2770: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.raft.sendMessage(msg))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2771</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2772</td>  <td class="nbHitsUncovered"><a title="Line 2772: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2772: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2773</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.debug(<span class="string">"canceling snapshot install for "</span> + follower + <span class="string">" due to failure to send "</span> + msg);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2774</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2775</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Message failed -&gt; snapshot is fatally wounded, so cancel it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2776</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    synced = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2777</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2778</td>  <td class="nbHitsUncovered"><a title="Line 2778: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2778: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (synced)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2779</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.info(<span class="string">"completed snapshot install for out-of-date "</span> + follower);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2780</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2781</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Snapshot transmit is complete (or failed)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2782</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.cancelSnapshotTransmit();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2783</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2784</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Trigger an immediate regular update</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2785</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setNextIndex(snapshotTransmit.getSnapshotIndex() + 1);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2786</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setSynced(synced);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2787</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.updateNow();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2788</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> UpdateFollowerService(follower));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2789</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2790</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2791</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2792</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Are we still waiting for the update timer to expire?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2793</td>  <td class="nbHitsUncovered"><a title="Line 2793: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2793: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!follower.getUpdateTimer().pollForTimeout()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2794</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">boolean</span> waitForTimerToExpire = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2795</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2796</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Don't wait for the update timer to expire if:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2797</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">//  (a) The follower is sync'd; AND</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2798</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">//      (y) We have a new log entry that the follower doesn't have; OR</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2799</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">//      (y) We have a new leaderCommit that the follower doesn't have</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2800</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// The effect is that we will pipeline updates to synchronized followers.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2801</td>  <td class="nbHitsUncovered"><a title="Line 2801: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2801: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">if</span> (follower.isSynced()</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2802</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  &amp;&amp; (follower.getLeaderCommit() != <span class="keyword">this</span>.raft.commitIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2803</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                   || follower.getNextIndex() &lt;= <span class="keyword">this</span>.raft.getLastLogIndex()))</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2804</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    waitForTimerToExpire = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2805</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2806</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Wait for timer to expire</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2807</td>  <td class="nbHitsUncovered"><a title="Line 2807: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2807: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (waitForTimerToExpire) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2808</td>  <td class="nbHitsUncovered"><a title="Line 2808: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2808: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2809</td>  <td class="nbHitsUncovered"><a title="Line 2809: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2809: Conditional coverage 0% (0/2).">                        <span class="keyword">this</span>.trace(<span class="string">"no update for \""</span> + follower.getIdentity() + <span class="string">"\": timer not expired yet, and follower is "</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2810</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                          + (follower.isSynced() ? <span class="string">"up to date"</span> : <span class="string">"not synced"</span>));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2811</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2812</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2813</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2814</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2815</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2816</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Get index of the next log entry to send to follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2817</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> nextIndex = follower.getNextIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2818</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2819</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If follower is too far behind, we must do a snapshot install</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2820</td>  <td class="nbHitsUncovered"><a title="Line 2820: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2820: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (nextIndex &lt;= <span class="keyword">this</span>.raft.lastAppliedIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2821</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> MostRecentView view = <span class="keyword">this</span>.raft.<span class="keyword">new</span> MostRecentView();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2822</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setSnapshotTransmit(<span class="keyword">new</span> SnapshotTransmit(<span class="keyword">this</span>.raft.getLastLogTerm(), <span class="keyword">this</span>.raft.getLastLogIndex(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2823</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.lastAppliedConfig, view.getSnapshot(), view.getView()));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2824</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"started snapshot install for out-of-date "</span> + follower);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2825</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> UpdateFollowerService(follower));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2826</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2827</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2828</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2829</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Restart update timer here (to avoid looping if an error occurs below)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2830</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            follower.getUpdateTimer().timeoutAfter(<span class="keyword">this</span>.raft.heartbeatTimeout);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2831</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2832</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Send actual data if follower is synced and there is a log entry to send; otherwise, just send a probe</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2833</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">final</span> AppendRequest msg;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2834</td>  <td class="nbHitsUncovered"><a title="Line 2834: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2834: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (!follower.isSynced() || nextIndex &gt; <span class="keyword">this</span>.raft.getLastLogIndex()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2835</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                msg = <span class="keyword">new</span> AppendRequest(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, peer, <span class="keyword">this</span>.raft.currentTerm, <span class="keyword">new</span> Timestamp(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2836</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.leaseTimeout, <span class="keyword">this</span>.raft.commitIndex, <span class="keyword">this</span>.raft.getLogTermAtIndex(nextIndex - 1), nextIndex - 1);   <span class="comment">// probe</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2837</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2838</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2839</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Get log entry to send</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2840</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LogEntry logEntry = <span class="keyword">this</span>.raft.getLogEntryAtIndex(nextIndex);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2841</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2842</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// If the log entry correspond's to follower's transaction, don't send the data because follower already has it.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2843</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// But only do this optimization the first time, in case something goes wrong on the follower's end.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2844</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                ByteBuffer mutationData = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2845</td>  <td class="nbHitsUncovered"><a title="Line 2845: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2845: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!follower.getSkipDataLogEntries().remove(logEntry)) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2846</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2847</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        mutationData = logEntry.getContent();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2848</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2849</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.error(<span class="string">"error reading log file "</span> + logEntry.getFile(), e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2850</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2851</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2852</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2853</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2854</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Create message</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2855</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                msg = <span class="keyword">new</span> AppendRequest(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, peer, <span class="keyword">this</span>.raft.currentTerm, <span class="keyword">new</span> Timestamp(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2856</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.leaseTimeout, <span class="keyword">this</span>.raft.commitIndex, <span class="keyword">this</span>.raft.getLogTermAtIndex(nextIndex - 1), nextIndex - 1,</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2857</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  logEntry.getTerm(), mutationData);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2858</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2859</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2860</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Send update</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2861</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">boolean</span> sent = <span class="keyword">this</span>.raft.sendMessage(msg);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2862</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2863</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Advance next index if a log entry was sent; we allow pipelining log entries when synchronized</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2864</td>  <td class="nbHitsUncovered"><a title="Line 2864: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2864: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (sent &amp;&amp; !msg.isProbe()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2865</td>  <td class="nbHitsUncovered"><a title="Line 2865: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2865: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> follower.isSynced();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2866</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setNextIndex(Math.min(follower.getNextIndex(), <span class="keyword">this</span>.raft.getLastLogIndex()) + 1);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2867</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2868</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2869</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update leaderCommit for follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2870</td>  <td class="nbHitsUncovered"><a title="Line 2870: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2870: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (sent)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2871</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setLeaderCommit(msg.getLeaderCommit());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2872</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2873</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2874</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateAllFollowersNow() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2875</td>  <td class="nbHitsUncovered"><a title="Line 2875: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2875: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2876</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.updateNow();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2877</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2878</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2879</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">class</span> UpdateFollowerService <span class="keyword">extends</span> Service {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2880</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2881</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">private</span> <span class="keyword">final</span> Follower follower;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2882</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2883</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            UpdateFollowerService(Follower follower) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2884</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">super</span>(LeaderRole.<span class="keyword">this</span>, <span class="string">"update follower \""</span> + follower.getIdentity() + <span class="string">"\""</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2885</td>  <td class="nbHitsUncovered"><a title="Line 2885: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2885: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> follower != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2886</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.follower = follower;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2887</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2888</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2889</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2890</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2891</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                LeaderRole.<span class="keyword">this</span>.updateFollower(<span class="keyword">this</span>.follower);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2892</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2893</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2894</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2895</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">boolean</span> equals(Object obj) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2896</td>  <td class="nbHitsUncovered"><a title="Line 2896: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2896: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (obj == <span class="keyword">null</span> || obj.getClass() != <span class="keyword">this</span>.getClass())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2897</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2898</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> UpdateFollowerService that = (UpdateFollowerService)obj;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2899</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.follower.equals(that.follower);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2900</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2901</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2902</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2903</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">int</span> hashCode() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2904</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.follower.hashCode();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2905</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2906</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2907</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2908</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Transactions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2909</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2910</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2911</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> checkReadyTransaction(<span class="keyword">final</span> RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2912</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2913</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2914</td>  <td class="nbHitsUncovered"><a title="Line 2914: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2914: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2915</td>  <td class="nbHitsUncovered"><a title="Line 2915: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2915: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2916</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2917</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check snapshot isolation</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2918</td>  <td class="nbHitsUncovered"><a title="Line 2918: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2918: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.checkReadyTransactionReadOnlySnapshot(tx))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2919</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2920</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2921</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check for conflict</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2922</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String error = <span class="keyword">this</span>.checkConflicts(tx.getBaseTerm(), tx.getBaseIndex(), tx.getMutableView().getReads());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2923</td>  <td class="nbHitsUncovered"><a title="Line 2923: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2923: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (error != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2924</td>  <td class="nbHitsUncovered"><a title="Line 2924: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2924: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2925</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"local transaction "</span> + tx + <span class="string">" failed due to conflict: "</span> + error);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2926</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, error);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2927</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2928</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2929</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle read-only vs. read-write transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2930</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Writes writes = tx.getMutableView().getWrites();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2931</td>  <td class="nbHitsUncovered"><a title="Line 2931: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2931: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (writes.isEmpty() &amp;&amp; tx.getConfigChange() == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2932</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2933</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Set commit term and index from last log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2934</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitTerm(<span class="keyword">this</span>.raft.getLastLogTerm());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2935</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitIndex(<span class="keyword">this</span>.raft.getLastLogIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2936</td>  <td class="nbHitsUncovered"><a title="Line 2936: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2936: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2937</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"commit is "</span> + tx.getCommitTerm() + <span class="string">"/"</span> + tx.getCommitIndex()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2938</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">" for local read-only transaction "</span> + tx);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2939</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2940</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2941</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// We will be able to commit this transaction immediately</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2942</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> CheckWaitingTransactionService(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2943</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2944</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2945</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Don't commit a new config change while there is any previous config change outstanding</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2946</td>  <td class="nbHitsUncovered"><a title="Line 2946: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2946: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (tx.getConfigChange() != <span class="keyword">null</span> &amp;&amp; <span class="keyword">this</span>.isConfigChangeOutstanding())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2947</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2948</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2949</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Commit transaction as a new log entry</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2950</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">final</span> LogEntry logEntry;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2951</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2952</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    logEntry = <span class="keyword">this</span>.applyNewLogEntry(<span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(tx));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2953</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2954</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error attempting to persist transaction"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2955</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2956</td>  <td class="nbHitsUncovered"><a title="Line 2956: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2956: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2957</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"added log entry "</span> + logEntry + <span class="string">" for local transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2958</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2959</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Set commit term and index from new log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2960</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitTerm(logEntry.getTerm());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2961</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitIndex(logEntry.getIndex());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2962</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2963</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// If there are no followers, we can commit this immediately</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2964</td>  <td class="nbHitsUncovered"><a title="Line 2964: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2964: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.followerMap.isEmpty())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2965</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> CheckWaitingTransactionService(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2966</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2967</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2968</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update transaction state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2969</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.setState(TxState.COMMIT_WAITING);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2970</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.getMutableView().disableReadTracking();                                  <span class="comment">// we no longer need this info</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2971</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2972</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2973</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2974</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> cleanupForTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2975</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// nothing to do</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2976</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2977</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2978</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">boolean</span> isConfigChangeOutstanding() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2979</td>  <td class="nbHitsUncovered"><a title="Line 2979: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2979: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (<span class="keyword">int</span> i = (<span class="keyword">int</span>)(<span class="keyword">this</span>.raft.commitIndex - <span class="keyword">this</span>.raft.lastAppliedIndex) + 1; i &lt; <span class="keyword">this</span>.raft.raftLog.size(); i++) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2980</td>  <td class="nbHitsUncovered"><a title="Line 2980: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2980: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.raft.raftLog.get(i).getConfigChange() != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2981</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2982</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2983</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2984</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2985</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2986</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Message</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2987</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2988</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2989</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseAppendRequest(AppendRequest msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2990</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failDuplicateLeader(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2991</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2992</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2993</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2994</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseAppendResponse(AppendResponse msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2995</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;2996</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Find follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2997</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Follower follower = <span class="keyword">this</span>.findFollower(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2998</td>  <td class="nbHitsUncovered"><a title="Line 2998: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 2998: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (follower == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;2999</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3000</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3001</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update follower's last rec'd leader timestamp</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3002</td>  <td class="nbHitsUncovered"><a title="Line 3002: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3002: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (msg.getLeaderTimestamp().compareTo(follower.getLeaderTimestamp()) &gt; 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3003</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setLeaderTimestamp(msg.getLeaderTimestamp());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3004</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.updateLeaseTimeoutService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3005</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3006</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3007</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Ignore if a snapshot install is in progress</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3008</td>  <td class="nbHitsUncovered"><a title="Line 3008: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3008: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (follower.getSnapshotTransmit() != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3009</td>  <td class="nbHitsUncovered"><a title="Line 3009: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3009: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3010</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"rec'd "</span> + msg + <span class="string">" while sending snapshot install; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3011</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3012</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3013</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3014</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Flag indicating we might want to update follower when done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3015</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">boolean</span> updateFollowerAgain = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3016</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3017</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update follower's match index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3018</td>  <td class="nbHitsUncovered"><a title="Line 3018: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3018: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (msg.getMatchIndex() &gt; follower.getMatchIndex()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3019</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setMatchIndex(msg.getMatchIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3020</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.updateLeaderCommitIndexService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3021</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.applyCommittedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3022</td>  <td class="nbHitsUncovered"><a title="Line 3022: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3022: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.currentConfig.containsKey(follower.getIdentity()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3023</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.updateKnownFollowersService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3024</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3025</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3026</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check result and update follower's next index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3027</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">boolean</span> wasSynced = follower.isSynced();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3028</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> previousNextIndex = follower.getNextIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3029</td>  <td class="nbHitsUncovered"><a title="Line 3029: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3029: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!msg.isSuccess())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3030</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.setNextIndex(Math.max(follower.getNextIndex() - 1, 1));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3031</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            follower.setSynced(msg.isSuccess());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3032</td>  <td class="nbHitsUncovered"><a title="Line 3032: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3032: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (follower.isSynced() != wasSynced) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3033</td>  <td class="nbHitsUncovered"><a title="Line 3033: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3033: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3034</td>  <td class="nbHitsUncovered"><a title="Line 3034: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3034: Conditional coverage 0% (0/2).">                    <span class="keyword">this</span>.debug(<span class="string">"sync status of \""</span> + follower.getIdentity() + <span class="string">"\" changed -&gt; "</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3035</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + (!follower.isSynced() ? <span class="string">"not "</span> : <span class="string">""</span>) + <span class="string">"synced"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3036</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3037</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                updateFollowerAgain = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3038</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3039</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3040</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Use follower's match index as a lower bound on follower's next index. This is needed because in this implementation,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3041</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// the application of leader log entries (to the state machine) may occur later than the application of follower log</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3042</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// entries, so it's possible a follower's state machine's index can advance past the leader's. In that case we want</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3043</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// to avoid the leader sending log entries that are prior to the follower's last committed index.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3044</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            follower.setNextIndex(Math.max(follower.getNextIndex(), follower.getMatchIndex() + 1));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3045</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3046</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Use follower's last log index as an upper bound on follower's next index.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3047</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            follower.setNextIndex(Math.min(msg.getLastLogIndex() + 1, follower.getNextIndex()));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3048</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3049</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update follower again if next index has changed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3050</td>  <td class="nbHitsUncovered"><a title="Line 3050: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3050: Conditional coverage 0% (0/2).">            updateFollowerAgain |= follower.getNextIndex() != previousNextIndex;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3051</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3052</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3053</td>  <td class="nbHitsUncovered"><a title="Line 3053: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3053: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3054</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.trace(<span class="string">"updated follower: "</span> + follower + <span class="string">", update again = "</span> + updateFollowerAgain);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3055</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3056</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Immediately update follower again (if appropriate)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3057</td>  <td class="nbHitsUncovered"><a title="Line 3057: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3057: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (updateFollowerAgain)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3058</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> UpdateFollowerService(follower));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3059</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3060</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3061</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3062</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseCommitRequest(CommitRequest msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3063</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3064</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Find follower</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3065</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Follower follower = <span class="keyword">this</span>.findFollower(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3066</td>  <td class="nbHitsUncovered"><a title="Line 3066: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3066: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (follower == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3067</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3068</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3069</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Decode reads</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3070</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">final</span> Reads reads;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3071</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3072</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                reads = Reads.deserialize(<span class="keyword">new</span> ByteBufferInputStream(msg.getReadsData()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3073</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3074</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.error(<span class="string">"error decoding reads data in "</span> + msg, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3075</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3076</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getTxId(), <span class="string">"error decoding reads data: "</span> + e));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3077</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3078</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3079</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3080</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check for conflict</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3081</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String conflictMsg = <span class="keyword">this</span>.checkConflicts(msg.getBaseTerm(), msg.getBaseIndex(), reads);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3082</td>  <td class="nbHitsUncovered"><a title="Line 3082: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3082: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (conflictMsg != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3083</td>  <td class="nbHitsUncovered"><a title="Line 3083: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3083: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3084</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"commit request "</span> + msg + <span class="string">" failed due to conflict: "</span> + conflictMsg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3085</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3086</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getTxId(), conflictMsg));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3087</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3088</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3089</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3090</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle read-only vs. read-write transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3091</td>  <td class="nbHitsUncovered"><a title="Line 3091: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3091: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (msg.isReadOnly()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3092</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3093</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Get current time</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3094</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Timestamp minimumLeaseTimeout = <span class="keyword">new</span> Timestamp();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3095</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3096</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// If no other leader could have been elected yet, the transaction may be committed immediately</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3097</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">final</span> CommitResponse response;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3098</td>  <td class="nbHitsUncovered"><a title="Line 3098: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3098: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.leaseTimeout.compareTo(minimumLeaseTimeout) &gt; 0) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3099</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3100</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Follower may commit as soon as it sees that the transaction's base log entry has been committed.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3101</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Note, we don't need to wait for subsequent log entries to be committed, because even if they</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3102</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// never are, whatever log entries replace them will necessarily get created sometime after now.</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3103</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    response = <span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3104</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      <span class="keyword">this</span>.raft.currentTerm, msg.getTxId(), msg.getBaseTerm(), msg.getBaseIndex());</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3105</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3106</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3107</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Remember that this follower is now going to be waiting for this particular leaseTimeout</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3108</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    follower.getCommitLeaseTimeouts().add(minimumLeaseTimeout);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3109</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3110</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Send immediate probes to all followers in an attempt to increase our leaseTimeout</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3111</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.updateAllFollowersNow();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3112</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3113</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Build response</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3114</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    response = <span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(), <span class="keyword">this</span>.raft.currentTerm,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3115</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      msg.getTxId(), <span class="keyword">this</span>.raft.getLastLogTerm(), <span class="keyword">this</span>.raft.getLastLogIndex(), minimumLeaseTimeout);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3117</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3118</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Send response</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3119</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(response);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3120</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">else</span> {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3121</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3122</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Commit mutations as a new log entry</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3123</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">final</span> LogEntry logEntry;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3124</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3125</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    logEntry = <span class="keyword">this</span>.applyNewLogEntry(<span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(msg.getMutationData()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3126</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3127</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"error appending new log entry for "</span> + msg, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3128</td>  <td class="nbHitsUncovered"><a title="Line 3128: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3128: Conditional coverage 0% (0/2).">                    <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3129</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      <span class="keyword">this</span>.raft.currentTerm, msg.getTxId(), e.getMessage() != <span class="keyword">null</span> ? e.getMessage() : <span class="string">""</span> + e));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3130</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3131</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3132</td>  <td class="nbHitsUncovered"><a title="Line 3132: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3132: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3133</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"added log entry "</span> + logEntry + <span class="string">" for remote "</span> + msg);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3134</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3135</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Follower transaction data optimization</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3136</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                follower.getSkipDataLogEntries().add(logEntry);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3137</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Send response</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3139</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> CommitResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getTxId(), <span class="keyword">this</span>.raft.getLastLogTerm(), <span class="keyword">this</span>.raft.getLastLogIndex()));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3141</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3142</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3145</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseCommitResponse(CommitResponse msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3146</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failDuplicateLeader(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3147</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3148</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3149</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3150</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseInstallSnapshot(InstallSnapshot msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3151</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failDuplicateLeader(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3152</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3153</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseRequestVote(RequestVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3157</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Too late dude, I already won the election</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3158</td>  <td class="nbHitsUncovered"><a title="Line 3158: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3158: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3159</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"ignoring "</span> + msg + <span class="string">" rec'd while in "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3160</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3161</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3162</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3163</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseGrantVote(GrantVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3164</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3165</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Thanks and all, but I already won the election</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3166</td>  <td class="nbHitsUncovered"><a title="Line 3166: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3166: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3167</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"ignoring "</span> + msg + <span class="string">" rec'd while in "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3168</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3169</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3170</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> failDuplicateLeader(Message msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3171</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3172</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// This should never happen - same term but two different leaders</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3173</td>  <td class="nbHitsUncovered"><a title="Line 3173: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3173: Conditional coverage 0% (0/2).">            <span class="keyword">final</span> <span class="keyword">boolean</span> defer = <span class="keyword">this</span>.raft.identity.compareTo(msg.getSenderId()) &lt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3174</td>  <td class="nbHitsUncovered"><a title="Line 3174: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3174: Conditional coverage 0% (0/2).">            <span class="keyword">this</span>.error(<span class="string">"detected a duplicate leader in "</span> + msg + <span class="string">" - should never happen; possible inconsistent cluster"</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3175</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">" configuration on "</span> + msg.getSenderId() + <span class="string">" (mine: "</span> + <span class="keyword">this</span>.raft.currentConfig + <span class="string">"); "</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3176</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (defer ? <span class="string">"reverting to follower"</span> : <span class="string">"ignoring"</span>));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3177</td>  <td class="nbHitsUncovered"><a title="Line 3177: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3177: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (defer)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3178</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>.raft, msg.getSenderId(), <span class="keyword">this</span>.raft.returnAddress));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3179</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3180</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3181</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3182</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3183</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3184</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3185</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.toStringPrefix()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3186</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">",followerMap="</span> + <span class="keyword">this</span>.followerMap</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3187</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"]"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3188</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3189</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3190</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3191</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3192</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3193</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">boolean</span> checkState() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3194</td>  <td class="nbHitsUncovered"><a title="Line 3194: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3194: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">super</span>.checkState())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3195</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3196</td>  <td class="nbHitsUncovered"><a title="Line 3196: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3196: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Follower follower : <span class="keyword">this</span>.followerMap.values()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3197</td>  <td class="nbHitsUncovered"><a title="Line 3197: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3197: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> follower.getNextIndex() &lt;= <span class="keyword">this</span>.raft.getLastLogIndex() + 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3198</td>  <td class="nbHitsUncovered"><a title="Line 3198: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3198: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> follower.getMatchIndex() &lt;= <span class="keyword">this</span>.raft.getLastLogIndex() + 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3199</td>  <td class="nbHitsUncovered"><a title="Line 3199: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3199: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> follower.getLeaderCommit() &lt;= <span class="keyword">this</span>.raft.commitIndex;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3200</td>  <td class="nbHitsUncovered"><a title="Line 3200: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3200: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">assert</span> follower.getUpdateTimer().isRunning() || follower.getSnapshotTransmit() != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3201</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3202</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">long</span> index = <span class="keyword">this</span>.raft.lastAppliedIndex - <span class="keyword">this</span>.appliedLogEntries.size() + 1;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3203</td>  <td class="nbHitsUncovered"><a title="Line 3203: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3203: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (LogEntry logEntry : Iterables.concat(<span class="keyword">this</span>.appliedLogEntries, <span class="keyword">this</span>.raft.raftLog))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3204</td>  <td class="nbHitsUncovered"><a title="Line 3204: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3204: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> logEntry.getIndex() == index++;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3205</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3206</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3207</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3208</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Internal methods</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3209</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3210</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3211</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Find the index of the most recent unapplied log entry having an associated config change matching the given predicate.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3212</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3213</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return most recent matching log entry, or zero if none found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3214</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3215</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">long</span> findMostRecentConfigChangeMatching(Predicate&lt;String[]&gt; predicate) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3216</td>  <td class="nbHitsUncovered"><a title="Line 3216: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3216: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (<span class="keyword">long</span> index = <span class="keyword">this</span>.raft.getLastLogIndex(); index &gt; <span class="keyword">this</span>.raft.lastAppliedIndex; index--) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3217</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> String[] configChange = <span class="keyword">this</span>.raft.getLogEntryAtIndex(index).getConfigChange();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3218</td>  <td class="nbHitsUncovered"><a title="Line 3218: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3218: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (configChange == <span class="keyword">null</span> &amp;&amp; predicate.apply(configChange))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3219</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> index;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3220</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3221</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> 0;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3222</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3223</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3224</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Apply a new log entry to the Raft log</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3225</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> LogEntry applyNewLogEntry(NewLogEntry newLogEntry) <span class="keyword">throws</span> Exception {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3226</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3227</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Do a couple of extra checks if a config change is included</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3228</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String[] configChange = newLogEntry.getData().getConfigChange();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3229</td>  <td class="nbHitsUncovered"><a title="Line 3229: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3229: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (configChange != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3230</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3231</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Disallow a config change while there is a previous uncommitted config change</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3232</td>  <td class="nbHitsUncovered"><a title="Line 3232: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3232: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.isConfigChangeOutstanding()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3233</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    newLogEntry.cancel();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3234</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> IllegalStateException(<span class="string">"uncommitted config change outstanding"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3235</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3236</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3237</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Disallow a configuration change that removes the last node in a cluster</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3238</td>  <td class="nbHitsUncovered"><a title="Line 3238: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3238: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (<span class="keyword">this</span>.raft.currentConfig.size() == 1 &amp;&amp; configChange[1] == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3239</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">final</span> String lastNode = <span class="keyword">this</span>.raft.currentConfig.keySet().iterator().next();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3240</td>  <td class="nbHitsUncovered"><a title="Line 3240: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3240: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (configChange[0].equals(lastNode)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3241</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        newLogEntry.cancel();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3242</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">"can't remove the last node in a cluster (\""</span> + lastNode + <span class="string">"\")"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3243</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3244</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3245</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3246</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3247</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Append a new entry to the Raft log</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3248</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">final</span> LogEntry logEntry;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3249</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">boolean</span> success = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3250</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3251</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                logEntry = <span class="keyword">this</span>.raft.appendLogEntry(<span class="keyword">this</span>.raft.currentTerm, newLogEntry);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3252</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                success = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3253</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">finally</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3254</td>  <td class="nbHitsUncovered"><a title="Line 3254: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3254: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!success)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3255</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    newLogEntry.cancel();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3256</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3257</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3258</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update follower list if configuration changed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3259</td>  <td class="nbHitsUncovered"><a title="Line 3259: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3259: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (configChange != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3260</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.updateKnownFollowersService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3261</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3262</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Prune applied log entries (check memory limit)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3263</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.pruneAppliedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3264</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3265</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update commit index (this is only needed if config has changed, or in the single node case)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3266</td>  <td class="nbHitsUncovered"><a title="Line 3266: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3266: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (configChange != <span class="keyword">null</span> || <span class="keyword">this</span>.followerMap.isEmpty())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3267</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.updateLeaderCommitIndexService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3268</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3269</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Immediately update all up-to-date followers</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3270</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.updateAllFollowersNow();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3271</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3272</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3273</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> logEntry;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3274</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3275</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3276</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3277</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check whether a proposed transaction can commit without any MVCC conflict.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3278</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3279</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param file file containing serialized copy of {@link writes} (content must already be fsync()'d to disk!)</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3280</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param baseTerm the term of the log entry on which the transaction is based</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3281</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param baseIndex the index of the log entry on which the transaction is based</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3282</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param reads reads performed by the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3283</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @param writes writes performed by the transaction</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3284</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * @return error message on failure, null for success</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3285</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3286</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> String checkConflicts(<span class="keyword">long</span> baseTerm, <span class="keyword">long</span> baseIndex, Reads reads) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3287</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3288</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Validate the index of the log entry on which the transaction is based</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3289</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> minIndex = <span class="keyword">this</span>.raft.lastAppliedIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3290</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> maxIndex = <span class="keyword">this</span>.raft.getLastLogIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3291</td>  <td class="nbHitsUncovered"><a title="Line 3291: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3291: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (baseIndex &lt; minIndex)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3292</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="string">"transaction is too old: snapshot index "</span> + baseIndex + <span class="string">" &lt; current state machine index "</span> + minIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3293</td>  <td class="nbHitsUncovered"><a title="Line 3293: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3293: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (baseIndex &gt; maxIndex)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3294</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="string">"transaction is too new: snapshot index "</span> + baseIndex + <span class="string">" &gt; most recent log index "</span> + maxIndex;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3295</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3296</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Validate the term of the log entry on which the transaction is based</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3297</td>  <td class="nbHitsUncovered"><a title="Line 3297: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3297: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (baseTerm != <span class="keyword">this</span>.raft.getLogTermAtIndex(baseIndex)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3298</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="string">"transaction is based on an overwritten log entry with index "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3299</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + baseIndex + <span class="string">" and term "</span> + baseTerm + <span class="string">" != "</span> + <span class="keyword">this</span>.raft.getLogTermAtIndex(baseIndex);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3300</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3301</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3302</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check for conflicts from intervening commits</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3303</td>  <td class="nbHitsUncovered"><a title="Line 3303: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3303: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (<span class="keyword">long</span> index = baseIndex + 1; index &lt;= maxIndex; index++) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3304</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> LogEntry logEntry = <span class="keyword">this</span>.raft.getLogEntryAtIndex(index);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3305</td>  <td class="nbHitsUncovered"><a title="Line 3305: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3305: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (reads.isConflict(logEntry.getWrites())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3306</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span> <span class="string">"writes of committed transaction at index "</span> + index</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3307</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">" conflict with transaction reads from transaction base index "</span> + baseIndex;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3308</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3309</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3310</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3311</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// No conflict</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3312</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3313</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3314</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3315</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> Follower findFollower(Message msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3316</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Follower follower = <span class="keyword">this</span>.followerMap.get(msg.getSenderId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3317</td>  <td class="nbHitsUncovered"><a title="Line 3317: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3317: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (follower == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3318</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.warn(<span class="string">"rec'd "</span> + msg + <span class="string">" from unknown follower \""</span> + msg.getSenderId() + <span class="string">"\", ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3319</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> follower;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3320</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3321</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3322</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3323</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3324</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Support superclass for {@link FollowerRole} and {@link CandidateRole}, which both have an election timer.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3325</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3326</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">abstract</span> <span class="keyword">static</span> <span class="keyword">class</span> NonLeaderRole <span class="keyword">extends</span> Role {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3327</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3328</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> Timer electionTimer = <span class="keyword">this</span>.raft.<span class="keyword">new</span> Timer(<span class="string">"election timer"</span>, <span class="keyword">new</span> Service(<span class="keyword">this</span>, <span class="string">"election timeout"</span>) {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3329</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3330</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3331</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                NonLeaderRole.<span class="keyword">this</span>.checkElectionTimeout();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3332</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3333</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        });</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3334</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">boolean</span> startElectionTimer;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3335</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3336</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Constructors</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3337</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3338</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> NonLeaderRole(RaftKVDatabase raft, <span class="keyword">boolean</span> startElectionTimer) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3339</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(raft);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3340</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.startElectionTimer = startElectionTimer;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3341</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3342</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3343</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3344</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3345</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3346</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> setup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3347</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.setup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3348</td>  <td class="nbHitsUncovered"><a title="Line 3348: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3348: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.startElectionTimer)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3349</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.restartElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3350</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3351</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3352</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3353</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> shutdown() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3354</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.shutdown();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3355</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.electionTimer.cancel();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3356</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3357</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3358</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3359</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3360</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check for an election timeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3361</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> checkElectionTimeout() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3362</td>  <td class="nbHitsUncovered"><a title="Line 3362: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3362: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.electionTimer.pollForTimeout()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3363</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"election timeout while in "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3364</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> CandidateRole(<span class="keyword">this</span>.raft));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3365</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3366</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3367</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3368</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">void</span> restartElectionTimer() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3369</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3370</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3371</td>  <td class="nbHitsUncovered"><a title="Line 3371: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3371: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3372</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3373</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Generate a randomized election timeout delay</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3374</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">int</span> range = <span class="keyword">this</span>.raft.maxElectionTimeout - <span class="keyword">this</span>.raft.minElectionTimeout;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3375</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">int</span> randomizedPart = Math.round(<span class="keyword">this</span>.raft.random.nextFloat() * range);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3376</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3377</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Restart timer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3378</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.electionTimer.timeoutAfter(<span class="keyword">this</span>.raft.minElectionTimeout + randomizedPart);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3379</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3380</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3381</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// MessageSwitch</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3382</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3383</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3384</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseAppendResponse(AppendResponse msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3385</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failUnexpectedMessage(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3386</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3387</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3388</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3389</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseCommitRequest(CommitRequest msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3390</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failUnexpectedMessage(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3391</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3392</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3393</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3394</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// FOLLOWER role</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3395</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3396</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> FollowerRole <span class="keyword">extends</span> NonLeaderRole {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3397</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3398</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> String leader;                                                          <span class="comment">// our leader, if known</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3399</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> String leaderAddress;                                                   <span class="comment">// our leader's network address</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3400</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> String votedFor;                                                        <span class="comment">// the candidate we voted for this term</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3401</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> SnapshotReceive snapshotReceive;                                        <span class="comment">// in-progress snapshot install, if any</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3402</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> HashMap&lt;Long, PendingRequest&gt; pendingRequests = <span class="keyword">new</span> HashMap&lt;&gt;();  <span class="comment">// wait for CommitResponse or log entry</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3403</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> HashMap&lt;Long, PendingWrite&gt; pendingWrites = <span class="keyword">new</span> HashMap&lt;&gt;();      <span class="comment">// wait for AppendRequest with null data</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3404</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> HashMap&lt;Long, Timestamp&gt; commitLeaderLeaseTimeoutMap              <span class="comment">// tx's waiting for leaderLeaseTimeout's</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3405</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;          = <span class="keyword">new</span> HashMap&lt;&gt;();</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3406</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> Timestamp lastLeaderMessageTime;                                        <span class="comment">// time of most recent rec'd AppendRequest</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3407</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> Timestamp leaderLeaseTimeout;                                           <span class="comment">// latest rec'd leader lease timeout</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3408</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3409</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Constructors</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3410</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3411</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> FollowerRole(RaftKVDatabase raft) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3412</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>(raft, <span class="keyword">null</span>, <span class="keyword">null</span>, <span class="keyword">null</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3413</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3414</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3415</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> FollowerRole(RaftKVDatabase raft, String leader, String leaderAddress) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3416</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>(raft, leader, leaderAddress, leader);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3417</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3418</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3419</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> FollowerRole(RaftKVDatabase raft, String leader, String leaderAddress, String votedFor) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3420</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(raft, raft.isClusterMember());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3421</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.leader = leader;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3422</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.leaderAddress = leaderAddress;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3423</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.votedFor = votedFor;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3424</td>  <td class="nbHitsUncovered"><a title="Line 3424: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3424: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.leaderAddress != <span class="keyword">null</span> || <span class="keyword">this</span>.leader == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3425</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3426</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3427</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3428</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3429</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3430</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> setup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3431</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.setup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3432</td>  <td class="nbHitsUncovered"><a title="Line 3432: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3432: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">this</span>.info(<span class="string">"entering follower role in term "</span> + <span class="keyword">this</span>.raft.currentTerm</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3433</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (<span class="keyword">this</span>.leader != <span class="keyword">null</span> ? <span class="string">"; with leader \""</span> + <span class="keyword">this</span>.leader + <span class="string">"\" at "</span> + <span class="keyword">this</span>.leaderAddress : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3434</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (<span class="keyword">this</span>.votedFor != <span class="keyword">null</span> ? <span class="string">"; having voted for \""</span> + <span class="keyword">this</span>.votedFor + <span class="string">"\""</span> : <span class="string">""</span>));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3435</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3436</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3437</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3438</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> shutdown() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3439</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.shutdown();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3440</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3441</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Cancel any in-progress snapshot install</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3442</td>  <td class="nbHitsUncovered"><a title="Line 3442: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3442: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.snapshotReceive != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3443</td>  <td class="nbHitsUncovered"><a title="Line 3443: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3443: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3444</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"aborting snapshot install due to leaving follower role"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3445</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.resetStateMachine(<span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3446</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3447</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3448</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3449</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Fail any (read-only) transactions waiting on a minimum lease timeout from deposed leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3450</td>  <td class="nbHitsUncovered"><a title="Line 3450: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3450: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">new</span> ArrayList&lt;RaftKVTransaction&gt;(<span class="keyword">this</span>.raft.openTransactions.values())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3451</td>  <td class="nbHitsUncovered"><a title="Line 3451: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3451: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (tx.getState().equals(TxState.COMMIT_WAITING) &amp;&amp; <span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.containsKey(tx.getTxId()))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3452</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.fail(tx, <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"leader was deposed during commit"</span>));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3453</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3454</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3455</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Cleanup pending requests and commit writes</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3456</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingRequests.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3457</td>  <td class="nbHitsUncovered"><a title="Line 3457: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3457: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (PendingWrite pendingWrite : <span class="keyword">this</span>.pendingWrites.values())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3458</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                pendingWrite.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3459</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingWrites.clear();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3460</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3461</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3462</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3463</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3464</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3465</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> outputQueueEmpty(String address) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3466</td>  <td class="nbHitsUncovered"><a title="Line 3466: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3466: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (address.equals(<span class="keyword">this</span>.leaderAddress))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3467</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkReadyTransactionsService);       <span class="comment">// TODO: track specific transactions</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3468</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3469</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3470</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check whether the required minimum leader lease timeout has been seen, if any</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3471</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3472</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">boolean</span> mayCommit(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3473</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3474</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Is there a required minimum leader lease timeout associated with the transaction?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3475</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Timestamp commitLeaderLeaseTimeout = <span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.get(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3476</td>  <td class="nbHitsUncovered"><a title="Line 3476: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3476: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (commitLeaderLeaseTimeout == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3477</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3478</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3479</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Do we know the leader's lease timeout yet?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3480</td>  <td class="nbHitsUncovered"><a title="Line 3480: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3480: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.leaderLeaseTimeout == <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3481</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3482</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3483</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Verify leader's lease timeout has extended beyond that required by the transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3484</td>  <td class="nbHitsUncovered"><a title="Line 3484: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3484: Conditional coverage 0% (0/2).">            <span class="keyword">return</span> <span class="keyword">this</span>.leaderLeaseTimeout.compareTo(commitLeaderLeaseTimeout) &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3485</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3486</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3487</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3488</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Check whether the election timer should be running, and make it so.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3489</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3490</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;p&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3491</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * This should be invoked:</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3492</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3493</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;After a log entry that contains a configuration change has been added to the log&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3494</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;When a snapshot install starts&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3495</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         *  &lt;li&gt;When a snapshot install completes&lt;/li&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3496</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * &lt;/ul&gt;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3497</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3498</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">void</span> updateElectionTimer() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3499</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">boolean</span> isClusterMember = <span class="keyword">this</span>.raft.isClusterMember();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3500</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">boolean</span> electionTimerRunning = <span class="keyword">this</span>.electionTimer.isRunning();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3501</td>  <td class="nbHitsUncovered"><a title="Line 3501: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3501: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (isClusterMember &amp;&amp; !electionTimerRunning) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3502</td>  <td class="nbHitsUncovered"><a title="Line 3502: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3502: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3503</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"starting up election timer because I'm now part of the current config"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3504</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.restartElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3505</td>  <td class="nbHitsUncovered"><a title="Line 3505: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3505: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            } <span class="keyword">else</span> <span class="keyword">if</span> (!isClusterMember &amp;&amp; electionTimerRunning) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3506</td>  <td class="nbHitsUncovered"><a title="Line 3506: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3506: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3507</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"stopping election timer because I'm no longer part of the current config"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3508</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.electionTimer.cancel();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3509</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3510</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3511</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3512</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Transactions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3513</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3514</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3515</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> checkReadyTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3516</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3517</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3518</td>  <td class="nbHitsUncovered"><a title="Line 3518: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3518: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3519</td>  <td class="nbHitsUncovered"><a title="Line 3519: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3519: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3520</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3521</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check snapshot isolation</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3522</td>  <td class="nbHitsUncovered"><a title="Line 3522: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3522: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.checkReadyTransactionReadOnlySnapshot(tx))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3523</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3524</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3525</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Did we already send a CommitRequest for this transaction?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3526</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            PendingRequest pendingRequest = <span class="keyword">this</span>.pendingRequests.get(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3527</td>  <td class="nbHitsUncovered"><a title="Line 3527: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3527: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (pendingRequest != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3528</td>  <td class="nbHitsUncovered"><a title="Line 3528: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3528: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3529</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"leaving alone ready tx "</span> + tx + <span class="string">" because request already sent"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3530</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3531</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3532</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3533</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If we are installing a snapshot, we must wait</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3534</td>  <td class="nbHitsUncovered"><a title="Line 3534: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3534: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.snapshotReceive != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3535</td>  <td class="nbHitsUncovered"><a title="Line 3535: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3535: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3536</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"leaving alone ready tx "</span> + tx + <span class="string">" because a snapshot install is in progress"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3537</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3538</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3539</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3540</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle situation where we are unconfigured and not part of any cluster yet</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3541</td>  <td class="nbHitsUncovered"><a title="Line 3541: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3541: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.isConfigured()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3542</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3543</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Get transaction mutations</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3544</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Writes writes = tx.getMutableView().getWrites();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3545</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> String[] configChange = tx.getConfigChange();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3546</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3547</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Allow an empty read-only transaction when unconfigured</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3548</td>  <td class="nbHitsUncovered"><a title="Line 3548: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3548: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (writes.isEmpty() &amp;&amp; configChange == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3549</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.succeed(tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3550</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3551</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3552</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3553</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Otherwise, we can only handle an initial config change that is adding the local node</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3554</td>  <td class="nbHitsUncovered"><a title="Line 3554: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3554: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">if</span> (configChange == <span class="keyword">null</span> || !configChange[0].equals(<span class="keyword">this</span>.raft.identity) || configChange[1] == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3555</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"unconfigured system: an initial configuration change adding"</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3556</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">" the local node (\""</span> + <span class="keyword">this</span>.raft.identity + <span class="string">"\") as the first member of a new cluster is required"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3557</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3558</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3559</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Create a new cluster if needed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3560</td>  <td class="nbHitsUncovered"><a title="Line 3560: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3560: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.raft.clusterId == 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3561</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.info(<span class="string">"creating new cluster"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3562</td>  <td class="nbHitsUncovered"><a title="Line 3562: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3562: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.joinCluster(0))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3563</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error persisting new cluster ID"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3564</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3565</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3566</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Advance term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3567</td>  <td class="nbHitsUncovered"><a title="Line 3567: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3567: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> <span class="keyword">this</span>.raft.currentTerm == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3568</td>  <td class="nbHitsUncovered"><a title="Line 3568: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3568: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.advanceTerm(<span class="keyword">this</span>.raft.currentTerm + 1))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3569</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error advancing term"</span>);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3570</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3571</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Append the first entry to the Raft log</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3572</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">final</span> LogEntry logEntry;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3573</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3574</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    logEntry = <span class="keyword">this</span>.raft.appendLogEntry(<span class="keyword">this</span>.raft.currentTerm, <span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(tx));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3575</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3576</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error attempting to persist transaction"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3577</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3578</td>  <td class="nbHitsUncovered"><a title="Line 3578: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3578: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3579</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"added log entry "</span> + logEntry + <span class="string">" for local transaction "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3580</td>  <td class="nbHitsUncovered"><a title="Line 3580: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3580: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> logEntry.getTerm() == 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3581</td>  <td class="nbHitsUncovered"><a title="Line 3581: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3581: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> logEntry.getIndex() == 1;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3582</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3583</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Set commit term and index from new log entry</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3584</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitTerm(logEntry.getTerm());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3585</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitIndex(logEntry.getIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3586</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.commitIndex = logEntry.getIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3587</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3588</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Update transaction state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3589</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setState(TxState.COMMIT_WAITING);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3590</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.getMutableView().disableReadTracking();                                  <span class="comment">// we no longer need this info</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3591</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3592</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Immediately become the leader of our new single-node cluster</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3593</td>  <td class="nbHitsUncovered"><a title="Line 3593: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3593: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> <span class="keyword">this</span>.raft.isConfigured();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3594</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"appointing myself leader in newly created cluster"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3595</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> LeaderRole(<span class="keyword">this</span>.raft));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3596</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3597</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3598</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3599</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If we don't have a leader yet, or leader's queue is full, we must wait</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3600</td>  <td class="nbHitsUncovered"><a title="Line 3600: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3600: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.leader == <span class="keyword">null</span> || <span class="keyword">this</span>.raft.isTransmitting(<span class="keyword">this</span>.leaderAddress)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3601</td>  <td class="nbHitsUncovered"><a title="Line 3601: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3601: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3602</td>  <td class="nbHitsUncovered"><a title="Line 3602: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3602: Conditional coverage 0% (0/2).">                    <span class="keyword">this</span>.trace(<span class="string">"leaving alone ready tx "</span> + tx + <span class="string">" because leader "</span></a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3603</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + (<span class="keyword">this</span>.leader == <span class="keyword">null</span> ? <span class="string">"is not known yet"</span> : <span class="string">"\""</span> + <span class="keyword">this</span>.leader + <span class="string">"\" is not writable yet"</span>));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3604</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3605</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3606</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3607</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3608</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Serialize reads into buffer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3609</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Reads reads = tx.getMutableView().getReads();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3610</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> readsDataSize = reads.serializedLength();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3611</td>  <td class="nbHitsUncovered"><a title="Line 3611: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3611: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (readsDataSize != (<span class="keyword">int</span>)readsDataSize)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3612</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"transaction read information exceeds maximum length"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3613</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> ByteBuffer readsData = Util.allocateByteBuffer((<span class="keyword">int</span>)readsDataSize);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3614</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">try</span> (ByteBufferOutputStream output = <span class="keyword">new</span> ByteBufferOutputStream(readsData)) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3615</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                reads.serialize(output);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3616</td>  <td class="nbHitsUncovered"><a title="Line 3616: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3616: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            } <span class="keyword">catch</span> (IOException e) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3617</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"unexpected exception"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3618</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3619</td>  <td class="nbHitsUncovered"><a title="Line 3619: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3619: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> !readsData.hasRemaining();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3620</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            readsData.flip();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3621</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3622</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Handle read-only vs. read-write transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3623</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Writes writes = tx.getMutableView().getWrites();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3624</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            FileWriter fileWriter = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3625</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            ByteBuffer mutationData = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3626</td>  <td class="nbHitsUncovered"><a title="Line 3626: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3626: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (!writes.isEmpty() || tx.getConfigChange() != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3627</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3628</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Serialize changes into a temporary file (but do not close or durably persist yet)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3629</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> File file = <span class="keyword">new</span> File(<span class="keyword">this</span>.raft.logDir,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3630</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  String.format(<span class="string">"%s%019d%s"</span>, TX_FILE_PREFIX, tx.getTxId(), TEMP_FILE_SUFFIX));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3631</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3632</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    LogEntry.writeData((fileWriter = <span class="keyword">new</span> FileWriter(file)), <span class="keyword">new</span> LogEntry.Data(writes, tx.getConfigChange()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3633</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    fileWriter.flush();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3634</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3635</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    fileWriter.getFile().delete();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3636</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Util.closeIfPossible(fileWriter);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3637</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error saving transaction mutations to temporary file"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3638</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3639</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> writeLength = fileWriter.getLength();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3640</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3641</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Load serialized writes from file</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3642</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3643</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    mutationData = Util.readFile(fileWriter.getFile(), writeLength);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3644</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3645</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    fileWriter.getFile().delete();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3646</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    Util.closeIfPossible(fileWriter);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3647</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">throw</span> <span class="keyword">new</span> KVTransactionException(tx, <span class="string">"error reading transaction mutations from temporary file"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3648</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3649</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3650</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Record pending commit write with temporary file</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3651</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> PendingWrite pendingWrite = <span class="keyword">new</span> PendingWrite(tx, fileWriter);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3652</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.pendingWrites.put(tx.getTxId(), pendingWrite);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3653</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3654</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3655</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Record pending request</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3656</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingRequests.put(tx.getTxId(), <span class="keyword">new</span> PendingRequest(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3657</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3658</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Send commit request to leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3659</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> CommitRequest msg = <span class="keyword">new</span> CommitRequest(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, <span class="keyword">this</span>.leader,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3660</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              <span class="keyword">this</span>.raft.currentTerm, tx.getTxId(), tx.getBaseTerm(), tx.getBaseIndex(), readsData, mutationData);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3661</td>  <td class="nbHitsUncovered"><a title="Line 3661: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3661: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3662</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.trace(<span class="string">"sending "</span> + msg + <span class="string">" to \""</span> + <span class="keyword">this</span>.leader + <span class="string">"\" for "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3663</td>  <td class="nbHitsUncovered"><a title="Line 3663: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3663: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.sendMessage(msg))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3664</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">throw</span> <span class="keyword">new</span> RetryTransactionException(tx, <span class="string">"error sending commit request to leader"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3665</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3666</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3667</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3668</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> cleanupForTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3669</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.pendingRequests.remove(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3670</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> PendingWrite pendingWrite = <span class="keyword">this</span>.pendingWrites.remove(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3671</td>  <td class="nbHitsUncovered"><a title="Line 3671: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3671: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (pendingWrite != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3672</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                pendingWrite.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3673</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.remove(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3674</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3675</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3676</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Messages</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3677</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3678</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3679</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">boolean</span> mayAdvanceCurrentTerm(Message msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3680</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3681</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Deny vote if we have heard from our leader within the minimum election timeout (dissertation, section 4.2.3)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3682</td>  <td class="nbHitsUncovered"><a title="Line 3682: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3682: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">            <span class="keyword">if</span> (msg <span class="keyword">instanceof</span> RequestVote</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3683</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              &amp;&amp; <span class="keyword">this</span>.lastLeaderMessageTime != <span class="keyword">null</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3684</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              &amp;&amp; <span class="keyword">this</span>.lastLeaderMessageTime.offsetFromNow() &gt; -<span class="keyword">this</span>.raft.minElectionTimeout)</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3685</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3686</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3687</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// OK</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3688</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3689</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3690</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3691</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3692</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseAppendRequest(AppendRequest msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3693</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3694</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Record new cluster ID if we haven't done so already</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3695</td>  <td class="nbHitsUncovered"><a title="Line 3695: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3695: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.raft.clusterId == 0)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3696</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.joinCluster(msg.getClusterId());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3697</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3698</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Record leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3699</td>  <td class="nbHitsUncovered"><a title="Line 3699: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3699: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!msg.getSenderId().equals(<span class="keyword">this</span>.leader)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3700</td>  <td class="nbHitsUncovered"><a title="Line 3700: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3700: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (<span class="keyword">this</span>.leader != <span class="keyword">null</span> &amp;&amp; !<span class="keyword">this</span>.leader.equals(msg.getSenderId())) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3701</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.error(<span class="string">"detected a conflicting leader in "</span> + msg + <span class="string">" (previous leader was \""</span> + <span class="keyword">this</span>.leader</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3702</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">"\") - should never happen; possible inconsistent cluster configuration (mine: "</span> + <span class="keyword">this</span>.raft.currentConfig</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3703</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                      + <span class="string">")"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3704</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3705</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.leader = msg.getSenderId();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3706</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.leaderAddress = <span class="keyword">this</span>.raft.returnAddress;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3707</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.leaderLeaseTimeout = msg.getLeaderLeaseTimeout();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3708</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"updated leader to \""</span> + <span class="keyword">this</span>.leader + <span class="string">"\" at "</span> + <span class="keyword">this</span>.leaderAddress);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3709</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkReadyTransactionsService);     <span class="comment">// allows COMMIT_READY transactions to be sent</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3710</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3711</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3712</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Get message info</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3713</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> leaderCommitIndex = msg.getLeaderCommit();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3714</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> leaderPrevTerm = msg.getPrevLogTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3715</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> leaderPrevIndex = msg.getPrevLogIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3716</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> logTerm = msg.getLogEntryTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3717</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> logIndex = leaderPrevIndex + 1;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3718</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3719</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update timestamp last heard from leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3720</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.lastLeaderMessageTime = <span class="keyword">new</span> Timestamp();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3721</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3722</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update leader's lease timeout</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3723</td>  <td class="nbHitsUncovered"><a title="Line 3723: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3723: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.leaderLeaseTimeout == <span class="keyword">null</span> || msg.getLeaderLeaseTimeout().compareTo(<span class="keyword">this</span>.leaderLeaseTimeout) &gt; 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3724</td>  <td class="nbHitsUncovered"><a title="Line 3724: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3724: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3725</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.trace(<span class="string">"advancing leader lease timeout "</span> + <span class="keyword">this</span>.leaderLeaseTimeout + <span class="string">" -&gt; "</span> + msg.getLeaderLeaseTimeout());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3726</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.leaderLeaseTimeout = msg.getLeaderLeaseTimeout();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3727</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkWaitingTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3728</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3729</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3730</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If a snapshot install is in progress, cancel it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3731</td>  <td class="nbHitsUncovered"><a title="Line 3731: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3731: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.snapshotReceive != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3732</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg + <span class="string">" during in-progress "</span> + <span class="keyword">this</span>.snapshotReceive</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3733</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">"; aborting snapshot install and resetting state machine"</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3734</td>  <td class="nbHitsUncovered"><a title="Line 3734: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3734: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.resetStateMachine(<span class="keyword">true</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3735</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3736</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3737</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.updateElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3738</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3739</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3740</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Restart election timeout (if running)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3741</td>  <td class="nbHitsUncovered"><a title="Line 3741: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3741: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.electionTimer.isRunning())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3742</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.restartElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3743</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3744</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Get my last log entry's index and term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3745</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">long</span> lastLogTerm = <span class="keyword">this</span>.raft.getLastLogTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3746</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">long</span> lastLogIndex = <span class="keyword">this</span>.raft.getLastLogIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3747</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3748</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check whether our previous log entry term matches that of leader; if not, or it doesn't exist, request fails</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3749</td>  <td class="nbHitsUncovered"><a title="Line 3749: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3749: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">            <span class="keyword">if</span> (leaderPrevIndex &lt; <span class="keyword">this</span>.raft.lastAppliedIndex</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3750</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              || leaderPrevIndex &gt; lastLogIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3751</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              || leaderPrevTerm != <span class="keyword">this</span>.raft.getLogTermAtIndex(leaderPrevIndex)) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3752</td>  <td class="nbHitsUncovered"><a title="Line 3752: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3752: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3753</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"rejecting "</span> + msg + <span class="string">" because previous log entry doesn't match"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3754</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> AppendResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3755</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getLeaderTimestamp(), <span class="keyword">false</span>, <span class="keyword">this</span>.raft.lastAppliedIndex, <span class="keyword">this</span>.raft.getLastLogIndex()));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3756</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3757</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3758</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3759</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check whether the message actually contains a log entry; if so, append it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3760</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">boolean</span> success = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3761</td>  <td class="nbHitsUncovered"><a title="Line 3761: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3761: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!msg.isProbe()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3762</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3763</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Check for a conflicting (i.e., never committed, then overwritten) log entry that we need to clear away first</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3764</td>  <td class="nbHitsUncovered"><a title="Line 3764: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3764: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">if</span> (logIndex &lt;= lastLogIndex &amp;&amp; <span class="keyword">this</span>.raft.getLogTermAtIndex(logIndex) != msg.getLogEntryTerm()) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3765</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3766</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Delete conflicting log entry, and all entries that follow it, from the log</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3767</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">final</span> <span class="keyword">int</span> startListIndex = (<span class="keyword">int</span>)(logIndex - <span class="keyword">this</span>.raft.lastAppliedIndex - 1);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3768</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">final</span> List&lt;LogEntry&gt; conflictList = <span class="keyword">this</span>.raft.raftLog.subList(startListIndex, <span class="keyword">this</span>.raft.raftLog.size());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3769</td>  <td class="nbHitsUncovered"><a title="Line 3769: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3769: Conditional coverage 0% (0/2).">                    <span class="keyword">for</span> (LogEntry logEntry : conflictList) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3770</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.info(<span class="string">"deleting log entry "</span> + logEntry + <span class="string">" overrwritten by "</span> + msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3771</td>  <td class="nbHitsUncovered"><a title="Line 3771: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3771: Conditional coverage 0% (0/2).">                        <span class="keyword">if</span> (!logEntry.getFile().delete())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3772</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            <span class="keyword">this</span>.error(<span class="string">"failed to delete log file "</span> + logEntry.getFile());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3773</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3774</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3775</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.raft.logDirChannel.force(<span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3776</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3777</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.warn(<span class="string">"errory fsync()'ing log directory "</span> + <span class="keyword">this</span>.raft.logDir, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3778</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3779</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    conflictList.clear();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3780</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3781</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Rebuild current config</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3782</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.currentConfig = <span class="keyword">this</span>.raft.buildCurrentConfig();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3783</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3784</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Update last log entry info</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3785</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    lastLogTerm = <span class="keyword">this</span>.raft.getLastLogTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3786</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    lastLogIndex = <span class="keyword">this</span>.raft.getLastLogIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3787</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3788</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3789</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Append the new log entry - if we don't already have it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3790</td>  <td class="nbHitsUncovered"><a title="Line 3790: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3790: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (logIndex &gt; lastLogIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3791</td>  <td class="nbHitsUncovered"><a title="Line 3791: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3791: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                    <span class="keyword">assert</span> logIndex == lastLogIndex + 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3792</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    LogEntry logEntry = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3793</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="keyword">do</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3794</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3795</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                        <span class="comment">// If message contains no data, we expect to get the data from the corresponding transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3796</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">final</span> ByteBuffer mutationData = msg.getMutationData();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3797</td>  <td class="nbHitsUncovered"><a title="Line 3797: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3797: Conditional coverage 0% (0/2).">                        <span class="keyword">if</span> (mutationData == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3798</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3799</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Find the matching pending commit write</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3800</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">final</span> PendingWrite pendingWrite;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3801</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3802</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                pendingWrite = Iterables.find(<span class="keyword">this</span>.pendingWrites.values(), <span class="keyword">new</span> Predicate&lt;PendingWrite&gt;() {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3803</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                    @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3804</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                    <span class="keyword">public</span> <span class="keyword">boolean</span> apply(PendingWrite pendingWrite) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3805</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                        <span class="keyword">final</span> RaftKVTransaction tx = pendingWrite.getTx();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3806</td>  <td class="nbHitsUncovered"><a title="Line 3806: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3806: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                                        <span class="keyword">return</span> tx.getState().equals(TxState.COMMIT_WAITING)</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3807</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                          &amp;&amp; tx.getCommitTerm() == logTerm &amp;&amp; tx.getCommitIndex() == logIndex;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3808</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3809</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                });</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3810</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            } <span class="keyword">catch</span> (NoSuchElementException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3811</td>  <td class="nbHitsUncovered"><a title="Line 3811: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3811: Conditional coverage 0% (0/2).">                                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3812</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                    <span class="keyword">this</span>.debug(<span class="string">"rec'd "</span> + msg + <span class="string">" but no read-write transaction matching commit "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3813</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                      + logTerm + <span class="string">"/"</span> + logIndex + <span class="string">" found; rejecting"</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3814</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3815</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3816</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3817</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3818</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Commit's writes are no longer pending</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3819</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            <span class="keyword">final</span> RaftKVTransaction tx = pendingWrite.getTx();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3820</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            <span class="keyword">this</span>.pendingWrites.remove(tx.getTxId());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3821</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3822</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Close and durably persist the associated temporary file</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3823</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3824</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                pendingWrite.getFileWriter().close();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3825</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3826</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">this</span>.error(<span class="string">"error closing temporary transaction file for "</span> + tx, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3827</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                pendingWrite.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3828</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3829</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3830</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3831</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Append a new log entry using temporary file</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3832</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3833</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                logEntry = <span class="keyword">this</span>.raft.appendLogEntry(logTerm,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3834</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                  <span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(tx, pendingWrite.getFileWriter().getFile()));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3835</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3836</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">this</span>.error(<span class="string">"error appending new log entry for "</span> + tx, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3837</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                pendingWrite.cleanup();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3838</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3839</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3840</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3841</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3842</td>  <td class="nbHitsUncovered"><a title="Line 3842: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3842: Conditional coverage 0% (0/2).">                            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3843</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">this</span>.debug(<span class="string">"now waiting for commit of "</span> + tx.getCommitTerm() + <span class="string">"/"</span> + tx.getCommitIndex()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3844</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                                  + <span class="string">" to commit "</span> + tx);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3845</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3846</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        } <span class="keyword">else</span> {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3847</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3848</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="comment">// Append new log entry normally using the data from the request</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3849</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3850</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                logEntry = <span class="keyword">this</span>.raft.appendLogEntry(logTerm, <span class="keyword">this</span>.raft.<span class="keyword">new</span> NewLogEntry(mutationData));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3851</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3852</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">this</span>.error(<span class="string">"error appending new log entry"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3853</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                                <span class="keyword">break</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3854</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3855</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3856</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    } <span class="keyword">while</span> (<span class="keyword">false</span>);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3857</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3858</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Start/stop election timer as needed</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3859</td>  <td class="nbHitsUncovered"><a title="Line 3859: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3859: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                    <span class="keyword">if</span> (logEntry != <span class="keyword">null</span> &amp;&amp; logEntry.getConfigChange() != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3860</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">this</span>.updateElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3861</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3862</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Success?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3863</td>  <td class="nbHitsUncovered"><a title="Line 3863: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3863: Conditional coverage 0% (0/2).">                    success = logEntry != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3864</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3865</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// Update last log entry info</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3866</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    lastLogTerm = <span class="keyword">this</span>.raft.getLastLogTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3867</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    lastLogIndex = <span class="keyword">this</span>.raft.getLastLogIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3868</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3869</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3870</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3871</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update my commit index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3872</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> newCommitIndex = Math.min(Math.max(leaderCommitIndex, <span class="keyword">this</span>.raft.commitIndex), lastLogIndex);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3873</td>  <td class="nbHitsUncovered"><a title="Line 3873: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3873: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (newCommitIndex &gt; <span class="keyword">this</span>.raft.commitIndex) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3874</td>  <td class="nbHitsUncovered"><a title="Line 3874: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3874: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3875</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"updating leader commit index from "</span> + <span class="keyword">this</span>.raft.commitIndex + <span class="string">" -&gt; "</span> + newCommitIndex);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3876</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.commitIndex = newCommitIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3877</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.checkWaitingTransactionsService);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3878</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">this</span>.applyCommittedLogEntriesService);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3879</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3880</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3881</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3882</td>  <td class="nbHitsUncovered"><a title="Line 3882: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3882: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3883</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.trace(<span class="string">"my updated follower state: "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3884</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">"term="</span> + <span class="keyword">this</span>.raft.currentTerm</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3885</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" commitIndex="</span> + <span class="keyword">this</span>.raft.commitIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3886</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" leaderLeaseTimeout="</span> + <span class="keyword">this</span>.leaderLeaseTimeout</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3887</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" lastApplied="</span> + <span class="keyword">this</span>.raft.lastAppliedTerm + <span class="string">"/"</span> + <span class="keyword">this</span>.raft.lastAppliedIndex</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3888</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" log="</span> + <span class="keyword">this</span>.raft.raftLog);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3889</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3890</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3891</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Send reply</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3892</td>  <td class="nbHitsUncovered"><a title="Line 3892: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3892: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (success) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3893</td>  <td class="nbHitsUncovered"><a title="Line 3893: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3893: Conditional coverage 0% (0/2).">                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> AppendResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3894</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getLeaderTimestamp(), <span class="keyword">true</span>, msg.isProbe() ? logIndex - 1 : logIndex,</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3895</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.getLastLogIndex()));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3896</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3897</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> AppendResponse(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, msg.getSenderId(),</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3898</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, msg.getLeaderTimestamp(), <span class="keyword">false</span>, <span class="keyword">this</span>.raft.lastAppliedIndex, <span class="keyword">this</span>.raft.getLastLogIndex()));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3899</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3900</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3901</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3902</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3903</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseCommitResponse(CommitResponse msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3904</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3905</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Find transaction</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3906</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> RaftKVTransaction tx = <span class="keyword">this</span>.raft.openTransactions.get(msg.getTxId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3907</td>  <td class="nbHitsUncovered"><a title="Line 3907: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3907: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (tx == <span class="keyword">null</span>)                                                                 <span class="comment">// must have been rolled back locally</span></a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3908</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3909</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3910</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check transaction state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3911</td>  <td class="nbHitsUncovered"><a title="Line 3911: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3911: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!tx.getState().equals(TxState.COMMIT_READY)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3912</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.warn(<span class="string">"rec'd "</span> + msg + <span class="string">" for "</span> + tx + <span class="string">" in state "</span> + tx.getState() + <span class="string">"; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3913</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3914</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3915</td>  <td class="nbHitsUncovered"><a title="Line 3915: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3915: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.pendingRequests.remove(tx.getTxId()) == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3916</td>  <td class="nbHitsUncovered"><a title="Line 3916: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3916: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3917</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.debug(<span class="string">"rec'd "</span> + msg + <span class="string">" for "</span> + tx + <span class="string">" not expecting a response; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3918</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3919</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3920</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3921</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check result</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3922</td>  <td class="nbHitsUncovered"><a title="Line 3922: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3922: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isTraceEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3923</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.trace(<span class="string">"rec'd "</span> + msg + <span class="string">" for "</span> + tx);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3924</td>  <td class="nbHitsUncovered"><a title="Line 3924: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3924: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (msg.isSuccess()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3925</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitTerm(msg.getCommitTerm());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3926</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setCommitIndex(msg.getCommitIndex());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3927</td>  <td class="nbHitsUncovered"><a title="Line 3927: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3927: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (msg.getCommitLeaderLeaseTimeout() != <span class="keyword">null</span>)</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3928</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.put(tx.getTxId(), msg.getCommitLeaderLeaseTimeout());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3929</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.setState(TxState.COMMIT_WAITING);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3930</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                tx.getMutableView().disableReadTracking();                                  <span class="comment">// we no longer need this info</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3931</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.requestService(<span class="keyword">new</span> CheckWaitingTransactionService(tx));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3932</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3933</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.fail(tx, <span class="keyword">new</span> RetryTransactionException(tx, msg.getErrorMessage()));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3934</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3935</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3936</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3937</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseInstallSnapshot(InstallSnapshot msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3938</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3939</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Restart election timer (if running)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3940</td>  <td class="nbHitsUncovered"><a title="Line 3940: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3940: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.electionTimer.isRunning())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3941</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.restartElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3942</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3943</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Do we have an existing install?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3944</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">boolean</span> startNewInstall = <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3945</td>  <td class="nbHitsUncovered"><a title="Line 3945: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3945: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.snapshotReceive != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3946</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3947</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// Does the message not match?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3948</td>  <td class="nbHitsUncovered"><a title="Line 3948: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3948: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.snapshotReceive.matches(msg)) {</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3949</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3950</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// If the message is NOT the first one in a new install, ignore it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3951</td>  <td class="nbHitsUncovered"><a title="Line 3951: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3951: Conditional coverage 0% (0/2).">                    <span class="keyword">if</span> (msg.getPairIndex() != 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3952</td>  <td class="nbHitsUncovered"><a title="Line 3952: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3952: Conditional coverage 0% (0/2).">                        <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3953</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                            <span class="keyword">this</span>.debug(<span class="string">"rec'd "</span> + msg + <span class="string">" which doesn't match in-progress "</span> + <span class="keyword">this</span>.snapshotReceive + <span class="string">"; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3954</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3955</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3956</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3957</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                    <span class="comment">// The message is the first one in a new install, so discard the existing install</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3958</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.info(<span class="string">"rec'd initial "</span> + msg + <span class="string">" with in-progress "</span> + <span class="keyword">this</span>.snapshotReceive + <span class="string">"; aborting previous install"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3959</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    startNewInstall = <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3960</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3961</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3962</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3963</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="comment">// If the message is NOT the first one in a new install, ignore it</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3964</td>  <td class="nbHitsUncovered"><a title="Line 3964: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3964: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (msg.getPairIndex() != 0) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3965</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.info(<span class="string">"rec'd non-initial "</span> + msg + <span class="string">" with no in-progress snapshot install; ignoring"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3966</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3967</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3968</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3969</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3970</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Get snapshot term and index</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3971</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> term = msg.getSnapshotTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3972</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">long</span> index = msg.getSnapshotIndex();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3973</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3974</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Set up new install if necessary</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3975</td>  <td class="nbHitsUncovered"><a title="Line 3975: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3975: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.snapshotReceive == <span class="keyword">null</span> || startNewInstall) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3976</td>  <td class="nbHitsUncovered"><a title="Line 3976: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3976: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> msg.getPairIndex() == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3977</td>  <td class="nbHitsUncovered"><a title="Line 3977: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3977: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.resetStateMachine(<span class="keyword">false</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3978</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3979</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.updateElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3980</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive = <span class="keyword">new</span> SnapshotReceive(</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3981</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  PrefixKVStore.create(<span class="keyword">this</span>.raft.kv, STATE_MACHINE_PREFIX), term, index, msg.getSnapshotConfig());</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3982</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"starting new snapshot install from \""</span> + msg.getSenderId() + <span class="string">"\" of "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3983</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + term + <span class="string">"/"</span> + index + <span class="string">" with config "</span> + msg.getSnapshotConfig());</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3984</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3985</td>  <td class="nbHitsUncovered"><a title="Line 3985: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3985: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.snapshotReceive.matches(msg);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3986</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;3987</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Apply next chunk of key/value pairs</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3988</td>  <td class="nbHitsUncovered"><a title="Line 3988: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3988: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3989</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"applying "</span> + msg + <span class="string">" to "</span> + <span class="keyword">this</span>.snapshotReceive);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3990</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3991</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive.applyNextChunk(msg.getData());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3992</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3993</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.error(<span class="string">"error applying snapshot to key/value store; resetting state machine"</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3994</td>  <td class="nbHitsUncovered"><a title="Line 3994: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 3994: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.resetStateMachine(<span class="keyword">true</span>))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3995</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3996</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.updateElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3997</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3998</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;3999</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4000</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4001</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// If that was the last chunk, finalize persistent state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4002</td>  <td class="nbHitsUncovered"><a title="Line 4002: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4002: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (msg.isLastChunk()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4003</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> Map&lt;String, String&gt; snapshotConfig = <span class="keyword">this</span>.snapshotReceive.getSnapshotConfig();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4004</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"snapshot install from \""</span> + msg.getSenderId() + <span class="string">"\" of "</span> + term + <span class="string">"/"</span> + index</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4005</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + <span class="string">" with config "</span> + snapshotConfig + <span class="string">" complete"</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4006</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.snapshotReceive = <span class="keyword">null</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4007</td>  <td class="nbHitsUncovered"><a title="Line 4007: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4007: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.recordLastApplied(term, index, snapshotConfig))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4008</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">this</span>.raft.resetStateMachine(<span class="keyword">true</span>);                          <span class="comment">// if this fails we are really screwed</span></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4009</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.updateElectionTimer();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4010</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4011</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4012</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4013</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4014</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseRequestVote(RequestVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4015</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4016</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Did we already vote for somebody else?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4017</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> String peer = msg.getSenderId();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4018</td>  <td class="nbHitsUncovered"><a title="Line 4018: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4018: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">if</span> (<span class="keyword">this</span>.votedFor != <span class="keyword">null</span> &amp;&amp; !<span class="keyword">this</span>.votedFor.equals(peer)) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4019</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg + <span class="string">"; rejected because we already voted for \""</span> + <span class="keyword">this</span>.votedFor + <span class="string">"\""</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4020</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4021</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4022</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4023</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Verify that we are allowed to vote for this peer</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4024</td>  <td class="nbHitsUncovered"><a title="Line 4024: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4024: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">            <span class="keyword">if</span> (msg.getLastLogTerm() &lt; <span class="keyword">this</span>.raft.getLastLogTerm()</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4025</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              || (msg.getLastLogTerm() == <span class="keyword">this</span>.raft.getLastLogTerm() &amp;&amp; msg.getLastLogIndex() &lt; <span class="keyword">this</span>.raft.getLastLogIndex())) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4026</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg + <span class="string">"; rejected because their log "</span> + msg.getLastLogTerm() + <span class="string">"/"</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4027</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + msg.getLastLogIndex() + <span class="string">" loses to ours "</span> + <span class="keyword">this</span>.raft.getLastLogTerm() + <span class="string">"/"</span> + <span class="keyword">this</span>.raft.getLastLogIndex());</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4028</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4029</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4030</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4031</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Persist our vote for this peer (if not already persisted)</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4032</td>  <td class="nbHitsUncovered"><a title="Line 4032: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4032: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.votedFor == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4033</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"granting vote to \""</span> + peer + <span class="string">"\" in term "</span> + <span class="keyword">this</span>.raft.currentTerm);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4034</td>  <td class="nbHitsUncovered"><a title="Line 4034: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4034: Conditional coverage 0% (0/2).">                <span class="keyword">if</span> (!<span class="keyword">this</span>.updateVotedFor(peer))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4035</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                    <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4036</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            } <span class="keyword">else</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4037</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"confirming existing vote for \""</span> + peer + <span class="string">"\" in term "</span> + <span class="keyword">this</span>.raft.currentTerm);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4038</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4039</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Send reply</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4040</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> GrantVote(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, peer, <span class="keyword">this</span>.raft.currentTerm));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4041</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4042</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4043</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4044</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseGrantVote(GrantVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4045</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4046</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Ignore - we already lost the election to the real leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4047</td>  <td class="nbHitsUncovered"><a title="Line 4047: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4047: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4048</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"ignoring "</span> + msg + <span class="string">" rec'd while in "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4049</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4050</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4051</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Helper methods</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4052</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4053</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4054</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         * Record the peer voted for in the current term.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4055</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">         */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4056</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">boolean</span> updateVotedFor(String recipient) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4057</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4058</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4059</td>  <td class="nbHitsUncovered"><a title="Line 4059: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4059: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4060</td>  <td class="nbHitsUncovered"><a title="Line 4060: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4060: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> recipient != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4061</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4062</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Update persistent store</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4063</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> Writes writes = <span class="keyword">new</span> Writes();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4064</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            writes.getPuts().put(VOTED_FOR_KEY, <span class="keyword">this</span>.raft.encodeString(recipient));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4065</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4066</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.kv.mutate(writes, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4067</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4068</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.error(<span class="string">"error persisting vote for \""</span> + recipient + <span class="string">"\""</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4069</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4070</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4071</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4072</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Done</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4073</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.votedFor = recipient;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4074</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4075</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4076</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4077</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4078</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4079</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4080</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4081</td>  <td class="nbHitsUncovered"><a title="Line 4081: Conditional coverage 0% (0/10) [each condition: 0%, 0%, 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4081: Conditional coverage 0% (0/10) [each condition: 0%, 0%, 0%, 0%, 0%].">            <span class="keyword">return</span> <span class="keyword">this</span>.toStringPrefix()</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4082</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (<span class="keyword">this</span>.leader != <span class="keyword">null</span> ? <span class="string">",leader=\""</span> + <span class="keyword">this</span>.leader + <span class="string">"\""</span> : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4083</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (<span class="keyword">this</span>.votedFor != <span class="keyword">null</span> ? <span class="string">",votedFor=\""</span> + <span class="keyword">this</span>.votedFor + <span class="string">"\""</span> : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4084</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (!<span class="keyword">this</span>.pendingRequests.isEmpty() ? <span class="string">",pendingRequests="</span> + <span class="keyword">this</span>.pendingRequests.keySet() : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4085</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (!<span class="keyword">this</span>.pendingWrites.isEmpty() ? <span class="string">",pendingWrites="</span> + <span class="keyword">this</span>.pendingWrites.keySet() : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4086</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + (!<span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.isEmpty() ? <span class="string">",leaseTimeouts="</span> + <span class="keyword">this</span>.commitLeaderLeaseTimeoutMap.keySet() : <span class="string">""</span>)</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4087</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"]"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4088</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4089</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4090</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4091</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4092</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4093</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">boolean</span> checkState() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4094</td>  <td class="nbHitsUncovered"><a title="Line 4094: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4094: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">super</span>.checkState())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4095</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4096</td>  <td class="nbHitsUncovered"><a title="Line 4096: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4096: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.leaderAddress != <span class="keyword">null</span> || <span class="keyword">this</span>.leader == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4097</td>  <td class="nbHitsUncovered"><a title="Line 4097: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4097: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.electionTimer.isRunning() == <span class="keyword">this</span>.raft.isClusterMember();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4098</td>  <td class="nbHitsUncovered"><a title="Line 4098: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4098: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Map.Entry&lt;Long, PendingRequest&gt; entry : <span class="keyword">this</span>.pendingRequests.entrySet()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4099</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> txId = entry.getKey();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4100</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> PendingRequest pendingRequest = entry.getValue();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4101</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> RaftKVTransaction tx = pendingRequest.getTx();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4102</td>  <td class="nbHitsUncovered"><a title="Line 4102: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4102: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> txId == tx.getTxId();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4103</td>  <td class="nbHitsUncovered"><a title="Line 4103: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4103: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4104</td>  <td class="nbHitsUncovered"><a title="Line 4104: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4104: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> tx.getCommitTerm() == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4105</td>  <td class="nbHitsUncovered"><a title="Line 4105: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4105: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> tx.getCommitIndex() == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4106</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4107</td>  <td class="nbHitsUncovered"><a title="Line 4107: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4107: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (Map.Entry&lt;Long, PendingWrite&gt; entry : <span class="keyword">this</span>.pendingWrites.entrySet()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4108</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> <span class="keyword">long</span> txId = entry.getKey();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4109</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> PendingWrite pendingWrite = entry.getValue();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4110</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">final</span> RaftKVTransaction tx = pendingWrite.getTx();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4111</td>  <td class="nbHitsUncovered"><a title="Line 4111: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4111: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> txId == tx.getTxId();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4112</td>  <td class="nbHitsUncovered"><a title="Line 4112: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4112: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">                <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY) || tx.getState().equals(TxState.COMMIT_WAITING);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4113</td>  <td class="nbHitsUncovered"><a title="Line 4113: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4113: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> pendingWrite.getFileWriter().getFile().exists();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4114</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4115</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4117</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4118</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// PendingRequest</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4119</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4120</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Represents a transaction in COMMIT_READY for which a CommitRequest has been sent to the leader</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4121</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// but no CommitResponse has yet been received</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4122</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">class</span> PendingRequest {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4123</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4124</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">private</span> <span class="keyword">final</span> RaftKVTransaction tx;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4125</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4126</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            PendingRequest(RaftKVTransaction tx) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4127</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.tx = tx;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4128</td>  <td class="nbHitsUncovered"><a title="Line 4128: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4128: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">                <span class="keyword">assert</span> !FollowerRole.<span class="keyword">this</span>.pendingRequests.containsKey(tx.getTxId());</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4129</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                FollowerRole.<span class="keyword">this</span>.pendingRequests.put(tx.getTxId(), <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4130</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4131</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4132</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> RaftKVTransaction getTx() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4133</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.tx;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4134</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4135</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4136</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4137</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// PendingWrite</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4139</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Represents a read-write transaction in COMMIT_READY or COMMIT_WAITING for which the server's AppendRequest</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// will have null mutationData, because we will already have the data on hand waiting in a temporary file. This</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4141</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// is a simple optimization to avoid sending the same data from leader -&gt; follower just sent from follower -&gt; leader.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4142</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">class</span> PendingWrite {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">private</span> <span class="keyword">final</span> RaftKVTransaction tx;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4145</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">private</span> <span class="keyword">final</span> FileWriter fileWriter;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4146</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4147</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            PendingWrite(RaftKVTransaction tx, FileWriter fileWriter) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4148</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.tx = tx;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4149</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.fileWriter = fileWriter;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4150</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4151</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4152</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> RaftKVTransaction getTx() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4153</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.tx;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> FileWriter getFileWriter() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4157</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">this</span>.fileWriter;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4158</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4159</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4160</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">public</span> <span class="keyword">void</span> cleanup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4161</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.fileWriter.getFile().delete();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4162</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                Util.closeIfPossible(<span class="keyword">this</span>.fileWriter);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4163</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4164</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4165</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4166</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4167</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// CANDIDATE role</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4168</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4169</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> CandidateRole <span class="keyword">extends</span> NonLeaderRole {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4170</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4171</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> <span class="keyword">final</span> HashSet&lt;String&gt; votes = <span class="keyword">new</span> HashSet&lt;&gt;();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4172</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4173</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Constructors</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4174</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4175</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> CandidateRole(RaftKVDatabase raft) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4176</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(raft, <span class="keyword">true</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4177</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4178</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4179</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Lifecycle</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4180</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4181</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4182</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> setup() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4183</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>.setup();</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4184</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4185</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Increment term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4186</td>  <td class="nbHitsUncovered"><a title="Line 4186: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4186: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">this</span>.raft.advanceTerm(<span class="keyword">this</span>.raft.currentTerm + 1))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4187</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4188</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4189</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Request votes from other peers</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4190</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> HashSet&lt;String&gt; voters = <span class="keyword">new</span> HashSet&lt;&gt;(<span class="keyword">this</span>.raft.currentConfig.keySet());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4191</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            voters.remove(<span class="keyword">this</span>.raft.identity);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4192</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"entering candidate role in term "</span> + <span class="keyword">this</span>.raft.currentTerm + <span class="string">"; requesting votes from "</span> + voters);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4193</td>  <td class="nbHitsUncovered"><a title="Line 4193: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4193: Conditional coverage 0% (0/2).">            <span class="keyword">for</span> (String voter : voters) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4194</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.sendMessage(<span class="keyword">new</span> RequestVote(<span class="keyword">this</span>.raft.clusterId, <span class="keyword">this</span>.raft.identity, voter,</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4195</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  <span class="keyword">this</span>.raft.currentTerm, <span class="keyword">this</span>.raft.getLastLogTerm(), <span class="keyword">this</span>.raft.getLastLogIndex()));</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4196</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4197</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4198</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4199</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Service</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4200</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4201</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4202</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> outputQueueEmpty(String address) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4203</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// nothing to do</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4204</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4205</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4206</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Transactions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4207</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4208</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4209</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> checkReadyTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4210</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4211</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Sanity check</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4212</td>  <td class="nbHitsUncovered"><a title="Line 4212: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4212: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>.raft);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4213</td>  <td class="nbHitsUncovered"><a title="Line 4213: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4213: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> tx.getState().equals(TxState.COMMIT_READY);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4214</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4215</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Check snapshot isolation</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4216</td>  <td class="nbHitsUncovered"><a title="Line 4216: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4216: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.checkReadyTransactionReadOnlySnapshot(tx))</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4217</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4218</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4219</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// We can't do anything with it until we have a leader</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4220</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4221</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4222</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4223</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> cleanupForTransaction(RaftKVTransaction tx) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4224</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// nothing to do</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4225</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4226</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4227</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// MessageSwitch</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4228</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4229</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4230</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseAppendRequest(AppendRequest msg) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4231</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"rec'd "</span> + msg + <span class="string">" in "</span> + <span class="keyword">this</span> + <span class="string">"; reverting to follower"</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4232</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> FollowerRole(<span class="keyword">this</span>.raft, msg.getSenderId(), <span class="keyword">this</span>.raft.returnAddress));</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4233</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.raft.receiveMessage(<span class="keyword">this</span>.raft.returnAddress, msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4234</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4235</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4236</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// MessageSwitch</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4237</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4238</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4239</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseCommitResponse(CommitResponse msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4240</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4241</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// We could not have ever sent a CommitRequest in this term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4242</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failUnexpectedMessage(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4243</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4244</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4245</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4246</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseInstallSnapshot(InstallSnapshot msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4247</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4248</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// We could not have ever sent an AppendResponse in this term</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4249</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.failUnexpectedMessage(msg);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4250</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4251</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4252</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4253</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseRequestVote(RequestVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4254</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4255</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Ignore - we are also a candidate and have already voted for ourself</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4256</td>  <td class="nbHitsUncovered"><a title="Line 4256: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4256: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (<span class="keyword">this</span>.log.isDebugEnabled())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4257</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.debug(<span class="string">"ignoring "</span> + msg + <span class="string">" rec'd while in "</span> + <span class="keyword">this</span>);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4258</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4259</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4260</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4261</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">void</span> caseGrantVote(GrantVote msg) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4262</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4263</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Record vote</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4264</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.votes.add(msg.getSenderId());</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4265</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.info(<span class="string">"rec'd election vote from \""</span> + msg.getSenderId() + <span class="string">"\" in term "</span> + <span class="keyword">this</span>.raft.currentTerm);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4266</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4267</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Tally votes</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4268</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">int</span> allVotes = <span class="keyword">this</span>.raft.currentConfig.size();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4269</td>  <td class="nbHitsUncovered"><a title="Line 4269: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4269: Conditional coverage 0% (0/2).">            <span class="keyword">final</span> <span class="keyword">int</span> numVotes = <span class="keyword">this</span>.votes.size() + (<span class="keyword">this</span>.raft.isClusterMember() ? 1 : 0);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4270</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">final</span> <span class="keyword">int</span> minVotes = allVotes / 2 + 1;                              <span class="comment">// require a majority</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4271</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4272</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="comment">// Did we win?</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4273</td>  <td class="nbHitsUncovered"><a title="Line 4273: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4273: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (numVotes &gt;= minVotes) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4274</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.info(<span class="string">"won the election for term "</span> + <span class="keyword">this</span>.raft.currentTerm + <span class="string">" with "</span></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4275</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                  + numVotes + <span class="string">"/"</span> + allVotes + <span class="string">" votes; BECOMING LEADER IN TERM "</span> + <span class="keyword">this</span>.raft.currentTerm);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4276</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.raft.changeRole(<span class="keyword">new</span> LeaderRole(<span class="keyword">this</span>.raft));</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4277</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4278</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4279</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4280</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4281</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4282</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4283</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4284</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">this</span>.toStringPrefix()</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4285</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">",votes="</span> + <span class="keyword">this</span>.votes</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4286</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;              + <span class="string">"]"</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4287</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4288</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4289</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">// Debug</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4290</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4291</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4292</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">boolean</span> checkState() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4293</td>  <td class="nbHitsUncovered"><a title="Line 4293: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4293: Conditional coverage 0% (0/2).">            <span class="keyword">if</span> (!<span class="keyword">super</span>.checkState())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4294</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4295</td>  <td class="nbHitsUncovered"><a title="Line 4295: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4295: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.electionTimer.isRunning();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4296</td>  <td class="nbHitsUncovered"><a title="Line 4296: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4296: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.raft.isClusterMember();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4297</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4298</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4299</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4300</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4301</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Prefix Functions</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4302</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4303</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">abstract</span> <span class="keyword">static</span> <span class="keyword">class</span> AbstractPrefixFunction&lt;F, T&gt; <span class="keyword">implements</span> Function&lt;F, T&gt; {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4304</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4305</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">final</span> <span class="keyword">byte</span>[] prefix;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4306</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4307</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        AbstractPrefixFunction(<span class="keyword">byte</span>[] prefix) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4308</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.prefix = prefix;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4309</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4310</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4311</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4312</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> PrefixKeyRangeFunction <span class="keyword">extends</span> AbstractPrefixFunction&lt;KeyRange, KeyRange&gt; {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4313</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4314</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        PrefixKeyRangeFunction(<span class="keyword">byte</span>[] prefix) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4315</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(prefix);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4316</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4317</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4318</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4319</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> KeyRange apply(KeyRange range) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4320</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> range.prefixedBy(<span class="keyword">this</span>.prefix);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4321</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4322</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4323</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4324</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> PrefixPutFunction <span class="keyword">extends</span> AbstractPrefixFunction&lt;Map.Entry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt;, Map.Entry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt;&gt; {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4325</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4326</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        PrefixPutFunction(<span class="keyword">byte</span>[] prefix) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4327</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(prefix);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4328</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4329</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4330</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4331</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> Map.Entry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt; apply(Map.Entry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt; entry) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4332</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">new</span> AbstractMap.SimpleEntry&lt;<span class="keyword">byte</span>[], <span class="keyword">byte</span>[]&gt;(Bytes.concat(<span class="keyword">this</span>.prefix, entry.getKey()), entry.getValue());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4333</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4334</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4335</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4336</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> PrefixAdjustFunction <span class="keyword">extends</span> AbstractPrefixFunction&lt;Map.Entry&lt;<span class="keyword">byte</span>[], Long&gt;, Map.Entry&lt;<span class="keyword">byte</span>[], Long&gt;&gt; {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4337</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4338</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        PrefixAdjustFunction(<span class="keyword">byte</span>[] prefix) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4339</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">super</span>(prefix);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4340</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4341</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4342</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4343</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> Map.Entry&lt;<span class="keyword">byte</span>[], Long&gt; apply(Map.Entry&lt;<span class="keyword">byte</span>[], Long&gt; entry) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4344</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span> <span class="keyword">new</span> AbstractMap.SimpleEntry&lt;<span class="keyword">byte</span>[], Long&gt;(Bytes.concat(<span class="keyword">this</span>.prefix, entry.getKey()), entry.getValue());</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4345</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4346</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4347</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4348</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Debug/Sanity Checking</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4349</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4350</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    <span class="keyword">private</span> <span class="keyword">abstract</span> <span class="keyword">class</span> ErrorLoggingRunnable <span class="keyword">implements</span> Runnable {</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4351</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4352</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        @Override</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4353</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4354</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;            <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4355</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                <span class="keyword">this</span>.doRun();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4356</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            } <span class="keyword">catch</span> (Throwable t) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4357</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                RaftKVDatabase.<span class="keyword">this</span>.error(<span class="string">"exception in callback"</span>, t);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4358</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4359</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4360</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4361</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">protected</span> <span class="keyword">abstract</span> <span class="keyword">void</span> doRun();</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4362</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4363</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4364</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">boolean</span> checkState() {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4365</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4366</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">this</span>.doCheckState();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4367</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        } <span class="keyword">catch</span> (AssertionError e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4368</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> AssertionError(<span class="string">"checkState() failure for \""</span> + <span class="keyword">this</span>.identity + <span class="string">"\""</span>, e);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4369</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4370</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4371</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4372</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4373</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">void</span> doCheckState() {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4374</td>  <td class="nbHitsUncovered"><a title="Line 4374: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4374: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> Thread.holdsLock(<span class="keyword">this</span>);</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4375</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4376</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Handle stopped state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4377</td>  <td class="nbHitsUncovered"><a title="Line 4377: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4377: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.role == <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4378</td>  <td class="nbHitsUncovered"><a title="Line 4378: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4378: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.kv == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4379</td>  <td class="nbHitsUncovered"><a title="Line 4379: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4379: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.random == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4380</td>  <td class="nbHitsUncovered"><a title="Line 4380: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4380: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.currentTerm == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4381</td>  <td class="nbHitsUncovered"><a title="Line 4381: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4381: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.commitIndex == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4382</td>  <td class="nbHitsUncovered"><a title="Line 4382: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4382: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedTerm == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4383</td>  <td class="nbHitsUncovered"><a title="Line 4383: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4383: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedIndex == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4384</td>  <td class="nbHitsUncovered"><a title="Line 4384: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4384: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedConfig == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4385</td>  <td class="nbHitsUncovered"><a title="Line 4385: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4385: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.currentConfig == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4386</td>  <td class="nbHitsUncovered"><a title="Line 4386: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4386: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.clusterId == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4387</td>  <td class="nbHitsUncovered"><a title="Line 4387: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4387: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.raftLog.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4388</td>  <td class="nbHitsUncovered"><a title="Line 4388: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4388: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.logDirChannel == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4389</td>  <td class="nbHitsUncovered"><a title="Line 4389: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4389: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.executor == <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4390</td>  <td class="nbHitsUncovered"><a title="Line 4390: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4390: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.transmitting.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4391</td>  <td class="nbHitsUncovered"><a title="Line 4391: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4391: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.openTransactions.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4392</td>  <td class="nbHitsUncovered"><a title="Line 4392: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4392: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.pendingService.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4393</td>  <td class="nbHitsUncovered"><a title="Line 4393: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4393: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> !<span class="keyword">this</span>.shuttingDown;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4394</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            <span class="keyword">return</span>;</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4395</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4396</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4397</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Handle running state</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4398</td>  <td class="nbHitsUncovered"><a title="Line 4398: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4398: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.kv != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4399</td>  <td class="nbHitsUncovered"><a title="Line 4399: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4399: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.random != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4400</td>  <td class="nbHitsUncovered"><a title="Line 4400: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4400: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.executor != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4401</td>  <td class="nbHitsUncovered"><a title="Line 4401: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4401: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.logDirChannel != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4402</td>  <td class="nbHitsUncovered"><a title="Line 4402: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4402: Conditional coverage 0% (0/6) [each condition: 0%, 0%, 0%].">        <span class="keyword">assert</span> !<span class="keyword">this</span>.executor.isShutdown() || <span class="keyword">this</span>.shuttingDown;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4403</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4404</td>  <td class="nbHitsUncovered"><a title="Line 4404: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4404: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.currentTerm &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4405</td>  <td class="nbHitsUncovered"><a title="Line 4405: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4405: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.commitIndex &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4406</td>  <td class="nbHitsUncovered"><a title="Line 4406: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4406: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedTerm &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4407</td>  <td class="nbHitsUncovered"><a title="Line 4407: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4407: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedIndex &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4408</td>  <td class="nbHitsUncovered"><a title="Line 4408: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4408: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedConfig != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4409</td>  <td class="nbHitsUncovered"><a title="Line 4409: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4409: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.currentConfig != <span class="keyword">null</span>;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4410</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4411</td>  <td class="nbHitsUncovered"><a title="Line 4411: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4411: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.currentTerm &gt;= <span class="keyword">this</span>.lastAppliedTerm;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4412</td>  <td class="nbHitsUncovered"><a title="Line 4412: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4412: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.commitIndex &gt;= <span class="keyword">this</span>.lastAppliedIndex;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4413</td>  <td class="nbHitsUncovered"><a title="Line 4413: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4413: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.commitIndex &lt;= <span class="keyword">this</span>.lastAppliedIndex + <span class="keyword">this</span>.raftLog.size();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4414</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">long</span> index = <span class="keyword">this</span>.lastAppliedIndex;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4415</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">long</span> term = <span class="keyword">this</span>.lastAppliedTerm;</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4416</td>  <td class="nbHitsUncovered"><a title="Line 4416: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4416: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (LogEntry logEntry : <span class="keyword">this</span>.raftLog) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4417</td>  <td class="nbHitsUncovered"><a title="Line 4417: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4417: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> logEntry.getIndex() == index + 1;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4418</td>  <td class="nbHitsUncovered"><a title="Line 4418: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4418: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> logEntry.getTerm() &gt;= term;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4419</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            index = logEntry.getIndex();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4420</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            term = logEntry.getTerm();</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4421</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4422</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4423</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check configured vs. unconfigured</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4424</td>  <td class="nbHitsUncovered"><a title="Line 4424: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4424: Conditional coverage 0% (0/2).">        <span class="keyword">if</span> (<span class="keyword">this</span>.isConfigured()) {</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4425</td>  <td class="nbHitsUncovered"><a title="Line 4425: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4425: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.clusterId != 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4426</td>  <td class="nbHitsUncovered"><a title="Line 4426: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4426: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.currentTerm &gt; 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4427</td>  <td class="nbHitsUncovered"><a title="Line 4427: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4427: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedTerm &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4428</td>  <td class="nbHitsUncovered"><a title="Line 4428: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4428: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedIndex &gt;= 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4429</td>  <td class="nbHitsUncovered"><a title="Line 4429: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4429: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> !<span class="keyword">this</span>.currentConfig.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4430</td>  <td class="nbHitsUncovered"><a title="Line 4430: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4430: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.currentConfig.equals(<span class="keyword">this</span>.buildCurrentConfig());</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4431</td>  <td class="nbHitsUncovered"><a title="Line 4431: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4431: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.getLastLogTerm() &gt; 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4432</td>  <td class="nbHitsUncovered"><a title="Line 4432: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4432: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.getLastLogIndex() &gt; 0;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4433</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">else</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4434</td>  <td class="nbHitsUncovered"><a title="Line 4434: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4434: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedTerm == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4435</td>  <td class="nbHitsUncovered"><a title="Line 4435: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4435: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedIndex == 0;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4436</td>  <td class="nbHitsUncovered"><a title="Line 4436: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4436: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.lastAppliedConfig.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4437</td>  <td class="nbHitsUncovered"><a title="Line 4437: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4437: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.currentConfig.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4438</td>  <td class="nbHitsUncovered"><a title="Line 4438: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4438: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">            <span class="keyword">assert</span> <span class="keyword">this</span>.raftLog.isEmpty();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4439</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4440</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4441</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check role</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4442</td>  <td class="nbHitsUncovered"><a title="Line 4442: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4442: Conditional coverage 0% (0/4) [each condition: 0%, 0%].">        <span class="keyword">assert</span> <span class="keyword">this</span>.role.checkState();</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4443</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4444</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="comment">// Check transactions</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4445</td>  <td class="nbHitsUncovered"><a title="Line 4445: Conditional coverage 0% (0/2).">&nbsp;0</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 4445: Conditional coverage 0% (0/2).">        <span class="keyword">for</span> (RaftKVTransaction tx : <span class="keyword">this</span>.openTransactions.values())</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4446</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;            tx.checkStateOpen(<span class="keyword">this</span>.currentTerm, <span class="keyword">this</span>.getLastLogIndex(), <span class="keyword">this</span>.commitIndex);</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;4447</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;    }</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4448</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;}</pre></td></tr>
<tr>  <td class="numLine">&nbsp;4449</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
</table>

<div class="footer">Report generated by <a href="http://cobertura.sourceforge.net/" target="_top">Cobertura</a> 2.0.3 on 5/28/15 8:10 PM.</div>
</body>
</html>
